location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } location /app1/ { proxy_pass http://localhost:8081/; root /angular-path/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; }
我可以去myurl.com/app1但它找不到我的静态文件。 所有这些文件仍然指向myurl.com我怎样才能解决这个问题?
编辑包括访问日志的完整configuration文件
[11/Jul/2017:19:10:12 +0000] "GET /bower_components/bootstrap/dist/css/bootstrap.css HTTP/1.1" 404 209 "https://www.myurl.com/app1/" server { listen 80; listen [::]:80; server_name myurl.com; return 301 https://www.myurl.com$request_uri; } server { listen 80; listen [::]:80; server_name www.myurl.com; return 301 https://$server_name$request_uri; } server { access_log /var/log/nginx/myurl_access.log; error_log /var/log/nginx/myurl_error.log warn; # SSL configuration listen 443 ssl; listen [::]:443 ssl; include snippets/ssl-myurl.com.conf; include snippets/ssl-params.conf; root /var/www/html; # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; server_name myurl.com www.myurl.com; location /app1/ { proxy_pass http://localhost:8081/; root /angular-app; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } location ~ /.well-known { allow all; } }