nginx反向代理不转发静态文件的解决办法
nginx反向代理不转发静态文件的解决办法
如代码所示,/serve/ 部分的代理不支持静态文件的,如css等
location ^~ /serve/ {proxy_pass http://127.0.0.1:8080/;}location ^~ /static/ {try_files $uri $uri/ @proxy_static;}location @proxy_static {proxy_pass http://127.0.0.1:8080;proxy_set_header Host 127.0.0.1;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;}
只能用upstream 方式
用 try_files,启用upstream代理,如果本地没有文件才代理。一定要加上proxy_set_header Host erp-serve.tj.local; 值与目示主机host一致,避免日志记录异常。