Score:1

change root directive value in server block with root directive in location block

pe flag

I have set a default directory for the nginx to look for the files, but when I try to access a certain location nginx such as / looks the default root folder /var/www/html/LiveStream/LiveStream-backend instead of what I specified in the location block /var/www/html/LiveStream/LiveStream-frontend/users/build for further detail my nginx configuartion file

log_format upstreamlog '$server_name to : $upstream_addr [$request]'
            'upstream_response_time $upstream_response_time'
            'msec $msec request-time $request_time';
upstream load_balance{
     ip_hash;
    server  localhost:3016;
}

server {

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;
    # listen [::]:443 ssl ipv6only=on; # managed by Certbot
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/ethiolive.net/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/ethiolive.net/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    
    add_header Content-Security-Policy upgrade-insecure-requests;   
    #SetEnvIf X-Forwarded-Proto https HTTPS=on
    #root /var/www/html/LiveStream/LiveStream-frontend;

    # Add index.php to the list if you are using PHP
    #index index.html index.htm index.nginx-debian.html;
    root /var/www/html/LiveStream/LiveStream-backend;
    server_name ethiolive.net www.ethiolive.net;
    
    location /api/ {
        root /var/www/html/LiveStream/LiveStream-backend;
        #alias /var/www/html/LiveStream/LiveStream-backend/public/;
        proxy_pass http://load_balance;
        proxy_http_version  1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host  $host;
        proxy_ssl_server_name on;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Real-IP         $remote_addr;
        proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_read_timeout 3600;
        proxy_headers_hash_max_size 512;
                proxy_headers_hash_bucket_size 128; 
        proxy_set_header Content-Security-Policy upgrade-insecure-requests;
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
    }
    location / {
        root /var/www/html/LiveStream/LiveStream-frontend/users/build;
        #add_header Content-Type text/plain;
                #return 200 'hello';
        index index.html index.htm;
        try_files $uri /index.html;
    }
    location /admin {
        
        alias /var/www/html/LiveStream/LiveStream-frontend/admin/build/;        
                index index.html index.htm;
        #add_header Content-Type text/plain;
        #return 200 index.html;
            try_files $uri $uri/ /index.html;
    }
    location /socket/ {
                proxy_pass http://load_balance/socket.io/;
        proxy_redirect          off;

                proxy_http_version      1.1;
                proxy_set_header        Upgrade                 $http_upgrade;
                proxy_set_header        Connection              "upgrade";
                proxy_set_header        Host                    $host;
                proxy_set_header        X-Real-IP               $remote_addr;
                proxy_set_header        X-Forwarded-For         $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Ssl on;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_headers_hash_max_size 512;
        proxy_headers_hash_bucket_size 128; 
    }               
    location /socket.io/{
                # add_header 'Access-Control-Allow-Origin' '*' always;
            #add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
            #add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;

                proxy_pass http://load_balance/socket.io/;
        proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Ssl on;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_headers_hash_max_size 512;
            proxy_headers_hash_bucket_size 128; 
    }
}
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.