当前位置: 首页 > 科技观察

网站404或空白怎么办?

时间:2023-03-22 15:38:01 科技观察

客户反馈:说他的网站是nginx代理后,打开是空白的。直接IP加地址访问就可以了(http://ip:port)。故障排除:(1)打开chrome浏览器访问,访问与客户描述的完全一致。(2)打开chrome,开发者工具,发现有些请求url是404,css和js(3)找到客户要登录服务器的账号,查看nginx配置文件upstreamwww.test.com{server127.0.0.1:8080;}服务器{listen80;listen443sslhttp2;ssl_certificate/usr/local/nginx/conf/ssl/www.test.com.pem;ssl_certificate_key/usr/local/nginx/conf/ssl/www.test。com.key;server_namewww.test.com;access_log/data/wwwlogs/www.test.com_nginx.logcombined;indexindex.htmlindex.htmindex.jsp;root/data/wwwroot/www.test.com;location~.*\.(js|css)?${expires7d;access_logoff;}location/{proxy_passhttp://www.test.com;includeproxy.conf;}}(4)上面的配置你有没有发现什么问题?一开始没注意,以为配置文件是的。打算查看nginx的日志,重新请求url,再次查看nginx,还是404。(感觉很迷糊),显然配置了proxy_passhttp://www.test.com。失败原因:因为拦截了“location~.*\.(js|css)?$”的匹配,请求无法正常发送到下一个“location/”,无法正常到达后端proxy_pass。解决方案:解决方案一:将后端静态文件(css和js)放到前端nginx机器/data/wwwroot/www.test.com解决方案二:修改配置文件upstreamwww.test。com{server127.0.0.1:8080;}server{listen80;listen443sslhttp2;ssl_certificate/usr/local/nginx/conf/ssl/www.test.com.pem;ssl_certificate_key/usr/local/nginx/conf/ssl/www.test.com.key;server_namewww.test.com;access_log/data/wwwlogs/www.test.com_nginx.logcombined;indexindex.htmlindex.htmindex.jsp;root/data/wwwroot/www.test.com;location~。*\.(js|css)?${proxy_passhttp://www.test.com;expires7d;access_logoff;}location/{proxy_passhttp://www.test.com;includeproxy.conf;}}