nginx The requested URL /404.html was not found on this serv
发布时间:2020-05-22 16:08:32 所属栏目:Linux 来源:互联网
导读:nginx The requested URL /404.html was not found on this server解决方法
使用django+nginx+gunicorn部署网站时,发现静态文件请求时,均报错 TherequestedURL/404.htmlwasnotfoundonthisserver chenxm.cc.conf server{#这个server标识我要配置了 listen80;#80是http默认的端口,443是https默认的端口(网页一般使用这两个端口) server_namewww.chenxm.cc;#你访问的路径前面的url名称 access_log/var/log/nginx/access.log;#Nginx日志配置 error_log/var/log/nginx/error.log;#Nginx错误日志配置 charsetutf-8;#Nginx编码 gzipon;#启用压缩,这个的作用就是给用户一个网页,比如3M压缩后1M这样传输速度就会提高很多 gzip_typestext/plainapplication/x-javascripttext/csstext/javascriptapplication/x-httpd-phpapplication/jsontext/jsonimage/jpegimage/gifimage/pngapplication/octet-stream;#支持压缩的类型 error_page404/404.html;#错误页面 error_page500502503504/50x.html;#错误页面 location/{ proxy_passhttp://0.0.0.0:8080; proxy_set_headerHost$host; proxy_set_headerX-Real-IP$remote_addr; proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for; } #指定静态文件路径 location/static/{ alias/home/chenxinming/chenCms/static; indexindex.htmlindex.htm; } } 打开nginx的error.log sudotail-n20/var/log/nginx/error.log 日志如下: 2019/07/2223:09:52[error]8441#8441:*11open()"/home/chenxinming/chenCms/staticdefault/script/superfish.js"failed(2:Nosuchfileordirectory),client:221.217.182.122,server:a.chenxm.cc,request:"GET/static/default/script/superfish.jsHTTP/1.1",host:"a.chenxm.cc",referrer:"http://a.chenxm.cc/" 2019/07/2223:09:52[error]8441#8441:*1open()"/home/chenxinming/chenCms/staticdefault/fonts/fontawesome-all.css"failed(2:Nosuchfileordirectory),request:"GET/static/default/fonts/fontawesome-all.cssHTTP/1.1",referrer:"http://a.chenxm.cc/" 2019/07/2223:09:52[error]8441#8441:*1open()"/home/chenxinming/chenCms/staticdefault/script/superfish.js"failed(2:Nosuchfileordirectory),referrer:"http://a.chenxm.cc/" 2019/07/2223:22:42[error]8441#8441:*114open()"/home/chenxinming/chenCms/staticdefault/plugin/layuiadmin/layui/css/layui.css"failed(2:Nosuchfileordirectory),request:"GET/static/default/plugin/layuiadmin/layui/css/layui.cssHTTP/1.1",host:"a.chenxm.cc" 检查了下静态文件实际路径和error.log中发现缺少了一个目录。经过排查原来是chenxm.cc中静态了路径少写了一个斜杠 如: location/static/{ alias/home/chenxinming/chenCms/static/; indexindex.htmlindex.htm; } (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读