我正在尝试为我的Django应用程序运行生产服务器,但是除根网页外,每个页面上都有404错误的问题。我可以通过url或ip地址访问它,并获取要呈现的主页,但其他任何页面均不起作用。
我的页面在沙盒服务器上工作,而404页面是nginx,而不是django 404页面,这使我认为这与我配置nginx网站可用文件的方式有关。
server {
listen 80;
server_name <url> www.<url> <ip_address>;
location = /favicon.ico {access_log off;log_not_found off;}
root /home/ubuntu/<directory>/mysite;
location = /static/ {
root /home/ubuntu/<directory>/mysite/;
}
location = /media/ {
root /home/ubuntu/<directory>/mysite/;
}
location = / {
include proxy_params;
proxy_pass http://unix:/home/ubuntu/<directory>/mysite/mysite.sock;
}
}
对于返回正确的页面,我得到了所有期望的静态文件(css,img)。我查看了nginx错误日志并获得了此信息:
2018/12/02 20:50:11 [error] 11506#11506: *3 open() "/home/ubuntu/<directory>/mysite/about.html" failed (2: No such file or directory), client: XXX.XXX.XXX.XXX, server: <url>, request: "GET /about.html HTTP/1.1", host: "www.<url>.com", referrer: "http://www.<url>.com/"
2018/12/02 20:55:41 [error] 11577#11577: *2 open() "/home/ubuntu/<directory>/mysite/about.html" failed (2: No such file or directory), client: XXX.XXX.XXX.XXX, server: <url>.com, request: "GET /about.html HTTP/1.1", host: "www.<url>.com", referrer: "http://www.<url>.com/"
2018/12/02 21:10:57 [error] 11577#11577: *4 open() "/home/ubuntu/<directory>/mysite/.git/HEAD" failed (2: No such file or directory), client: XXX.XXX.XXX.XXX, server: <url>.com, request: "GET /.git/HEAD HTTP/1.1", host: "XXX.XXX.XXX.XXX"
2018/12/02 21:11:44 [error] 11577#11577: *7 open() "/home/ubuntu/<directory>/mysite/about.html" failed (2: No such file or directory), client: XXX.XXX.XXX.XXX, server: <url>.com, request: "GET /about.html HTTP/1.1", host: "www.<url>.com", referrer: "http://www.<url>.com/"
任何帮助都可以。谢谢。