加入收藏 | 设为首页 | 会员中心 | 我要投稿 辽源站长网 (https://www.0437zz.com/)- 云专线、云连接、智能数据、边缘计算、数据安全!
当前位置: 首页 > 服务器 > 搭建环境 > Windows > 正文

网站404或空白怎么办?

发布时间:2019-08-29 11:47:22 所属栏目:Windows 来源:Tom-时光
导读:客户反映:说自己的网站走nginx代理后,打开空白。直接IP加地址访问是好的(http://ip:port)。 故障排查: (1) 打开chrome浏览器,访问了下,访问情况真是客户描述的那样。 (2) 感觉打开chrome ,开发者工具,发现部分请求URL是404,css和js的 (3) 找客户要

客户反映:说自己的网站走nginx代理后,打开空白。直接IP加地址访问是好的(http://ip:port)。

网站404或空白怎么办?

故障排查:

(1) 打开chrome浏览器,访问了下,访问情况真是客户描述的那样。

(2) 感觉打开chrome ,开发者工具,发现部分请求URL是404,css和js的

网站404或空白怎么办?

(3) 找客户要服务器登录的账号,检查nginx配置文件

  1. upstream www.test.com{ 
  2.   server 127.0.0.1:8080; 
  3. server { 
  4.   listen 80; 
  5.   listen 443 ssl http2; 
  6.   ssl_certificate /usr/local/nginx/conf/ssl/www.test.com.pem; 
  7.   ssl_certificate_key /usr/local/nginx/conf/ssl/www.test.com.key; 
  8.   server_name www.test.com; 
  9.   access_log /data/wwwlogs/www.test.com_nginx.log combined; 
  10.   index index.html index.htm index.jsp; 
  11.   root /data/wwwroot/www.test.com; 
  12.      
  13.   
  14.   location ~ .*.(js|css)?$ { 
  15.     
  16.     expires 7d; 
  17.     access_log off; 
  18.   } 
  19.  
  20.   location / { 
  21.     proxy_pass http://www.test.com; 
  22.     include proxy.conf; 
  23.   } 

(4) 大家有发现上面配置有问题不?刚开始我也没有注意,自认为配置文件是对 的。

打算检查nginx的日志,一遍请求URL,一遍查看nginx果然还是404.(感觉疑惑),明明配置了proxy_pass http://www.test.com。

故障原因:

是因为 “location ~ .*.(js|css)?$” 这个匹配拦截掉了,请求不能正常发往下一个“location /” ,也就不能正常抵达后端proxy_pass了。

解决方法:

第一种解决方法:是将后端的静态文件(css 和js ),放入前置nginx 机器/data/wwwroot/www.test.com

第二种解决方法 :修改配置文件

  1. upstream www.test.com{ 
  2.   server 127.0.0.1:8080; 
  3. server { 
  4.   listen 80; 
  5.   listen 443 ssl http2; 
  6.   ssl_certificate /usr/local/nginx/conf/ssl/www.test.com.pem; 
  7.   ssl_certificate_key /usr/local/nginx/conf/ssl/www.test.com.key; 
  8.   server_name www.test.com; 
  9.   access_log /data/wwwlogs/www.test.com_nginx.log combined; 
  10.   index index.html index.htm index.jsp; 
  11.   root /data/wwwroot/www.test.com; 
  12.      
  13.  
  14.   location ~ .*.(js|css)?$ { 
  15.       proxy_pass http://www.test.com; 
  16.     expires 7d; 
  17.     access_log off; 
  18.   } 
  19.  
  20.   location / { 
  21.     proxy_pass http://www.test.com; 
  22.     include proxy.conf; 
  23.   } 

【编辑推荐】

  1. Windows 10中没有文本的空或空白对话框
  2. 官宣:F5 已完成对 NGINX 的收购
  3. 大流量、高负载场景 Nginx+Linux 性能调优
  4. Nginx 如何配置防盗链
  5. Nginx 如何限制访问频率,下载速率和并发连接数
【责任编辑:赵宁宁 TEL:(010)68476606】
点赞 0

(编辑:辽源站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读