全球主机交流论坛
标题:
不懂就问 大佬们nginx反代后静态文件(jpg,css)全部404
[打印本页]
作者:
下①站↗幸福
时间:
2019-11-16 00:42
标题:
不懂就问 大佬们nginx反代后静态文件(jpg,css)全部404
将127.0.0.1/tomcat/反代到127.0.0.1:8080
location是这么写的
location /tomcat/ {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
复制代码
然后访问127.0.0.1/tomcat/页面能正常显示 但是所有css jpg这些静态文件 全部404
用chrome的审查元素看 比如原文件是tomcat.css 会被连接到http://127.0.0.1/tomcat/tomcat.css而不是http://127.0.0.1:8080/tomcat.css
查了好多网上有相同问题的 好多方法都试了也没解决掉
作者:
squalll
时间:
2019-11-16 01:08
location / {
proxy_pass http://127.0.0.1:8080/;
}
别的都别写,直接试下
作者:
scyuns
时间:
2019-11-16 01:40
try_files 加上目录试试了
欢迎光临 全球主机交流论坛 (https://443502.xyz/)
Powered by Discuz! X3.4