nginx proxy_pass静态资产

时间:2015-02-13 21:29:45

标签: nginx proxypass

我有以下nginx配置

rewrite_log on;
server {
 server_name greymarmita.no-ip.org;
 listen 80;
 rewrite ^(.*) https://$host$1 permanent;
}
server {
 server_name greymarmita.no-ip.org;
 listen 443 ssl;
 error_log /var/log/nginx/main.error;
 access_log /var/log/nginx/main.access;
 ssl on;
 ssl_certificate /etc/ssl/localcerts/autosigned.crt;
 ssl_certificate_key /etc/ssl/localcerts/autosigned.key;
 root /srv/www;
 index index.html /index.html;

 location /rasp/ {
   proxy_pass http://192.168.2.6:81/;
  }
 location /cam/ {
   proxy_pass http://192.168.2.4:8081;
 }
 location ^~ /router/ {
   proxy_pass http://192.168.2.1/;
 }


location /nas/ {
  proxy_pass http://192.168.2.13/;
  proxy_redirect    off;
  proxy_set_header  Host            $host;
  proxy_set_header  X-Real-IP       $remote_addr;
  proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
}

}

然而,当我尝试访问http://192.168.2.6/nas但是html文件正确提供时,/ web /下的文件不是

获取https://greymarmita.no-ip.org/web/images/login.png 404(未找到)

这些资产的正确路径应为https://greymarmita.no-ip.org/nas/web/images/login.png

1 个答案:

答案 0 :(得分:0)

您没有与该文件匹配的位置,请尝试添加此

location / {
  try_files $uri $uri/;
}