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 {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/ethiolive.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ethiolive.net/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
add_header Content-Security-Policy upgrade-insecure-requests;
root /var/www/html/LiveStream/LiveStream-backend;
server_name ethiolive.net www.ethiolive.net;
location /api/ {
root /var/www/html/LiveStream/LiveStream-backend;
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;
}
location / {
root /var/www/html/LiveStream/LiveStream-frontend/users/build;
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;
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/{
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;
}
}