使用django+Nginx+gunicorn部署网站时,发现静态文件请求时,均报错@H_301_1@
The requested URL /404.HTML was not found on this server
chenxm.cc.conf@H_301_1@
server { # 这个server标识我要配置了 Listen 80; # 80 是http默认的端口, 443 是https默认的端口(网页一般使用这两个端口) server_name www.chenxm.cc ; # 你访问的路径前面的url名称 access_log /var/log/Nginx/access.log; # Nginx日志配置 error_log /var/log/Nginx/error.log; # Nginx错误日志配置 charset utf-8; # Nginx编码 gzip on; # 启用压缩,这个的作用就是给用户一个网页,比如3M压缩后1M这样传输速度就会提高很多 gzip_types text/plain application/x-JavaScript text/CSS text/JavaScript application/x-httpd-PHP application/Json text/Json image/jpeg image/gif image/png application/octet-stream; # 支持压缩的类型 error_page 404 /404.HTML; # 错误页面 error_page 500 502 503 504 /50x.HTML; # 错误页面 location / { proxy_pass http://0.0.0.0: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; } # 指定静态文件路径 location /static/ { alias /home/chenxinming/chenCMS/static; index index.HTML index.htm; } }
打开Nginx的error.log
sudo tail -n 20 /var/log/Nginx/error.log
日志如下:
2019/07/22 23:09:52 [error] 8441#8441: *11 open() "/home/chenxinming/chenCMS/staticdefault/script/superfish.Js" Failed (2: No such file or directory), clIEnt: 221.217.182.122, server: a.chenxm.cc, request: "GET /static/default/script/superfish.Js http/1.1", host: "a.chenxm.cc", referrer: "http://a.chenxm.cc/"2019/07/22 23:09:52 [error] 8441#8441: *1 open() "/home/chenxinming/chenCMS/staticdefault/Fonts/Fontawesome-all.CSS" Failed (2: No such file or directory), request: "GET /static/default/Fonts/Fontawesome-all.CSS http/1.1", referrer: "http://a.chenxm.cc/"2019/07/22 23:09:52 [error] 8441#8441: *1 open() "/home/chenxinming/chenCMS/staticdefault/script/superfish.Js" Failed (2: No such file or directory), referrer: "http://a.chenxm.cc/"2019/07/22 23:22:42 [error] 8441#8441: *114 open() "/home/chenxinming/chenCMS/staticdefault/plugin/layuiadmin/layui/CSS/layui.CSS" Failed (2: No such file or directory), request: "GET /static/default/plugin/layuiadmin/layui/CSS/layui.CSS http/1.1", host: "a.chenxm.cc"
检查了下静态文件实际路径和error.log中发现缺少了一个目录。经过排查原来是chenxm.cc中静态了路径少写了一个斜杠
如:
location /static/ { alias /home/chenxinming/chenCMS/static/; index index.HTML index.htm; }
@H_301_1@
总结以上是内存溢出为你收集整理的nginx The requested URL /404.html was not found on this server解决方法全部内容,希望文章能够帮你解决nginx The requested URL /404.html was not found on this server解决方法所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)