我已经设置了一个默认目录来nginx
查找文件,但是当我尝试访问某个位置时,nginx 会/
查找默认的根文件夹/var/www/html/LiveStream/LiveStream-backend
,而不是我在位置块中指定的文件,/var/www/html/LiveStream/LiveStream-frontend/users/build
有关详细信息,请参阅我的 nginx 配置文件
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;
}
}