【发布时间】:2019-04-20 14:49:36
【问题描述】:
在本地运行 django 项目时,我可以访问我的 home、admin、app1、app2 目录(即
localhost:portnum , localhost:portnum/admin ,
localhost:portnum/app1 , localhost:portnum/app2)
当我在服务器中部署应用程序时问题就开始了(我在guide 的帮助下使用 nginx 和 gunicorn 进行 django 部署)
问题:- 我无法访问 example.com/admin、example.com/app1、example.com/app2。 无论如何,我都可以访问我的主页 example.com。
当我尝试访问 example.com/app1/ 页面时出现错误 403 禁止
2018/11/17 18:00:55 [error] 28459#28459: *8 directory index of "/home/ubuntu/project/app/" is forbidden, client: 172.68.146.88, server: example.com, request: "GET /events/ HTTP/1.1", host: "www.example.com"
2018/11/17 18:00:58 [error] 28459#28459: *13 open() "/usr/share/nginx/html/app" failed (2: No such file or directory), client: 172.68.146.10, server: example.com, request: "GET /events HTTP/1.1", host: "www.example.com"
我在这个问题之前尝试遵循的一些解决方案::-
- Django: when trying domain.com/admin gives 404 with an old unexisting urls file
-
Nginx 403 error: directory index of [folder] is forbidden
我的 nginx 配置
server {
listen 80;
listen 443;
ssl on;
ssl_certificate /home/ubuntu/certs/cert.pem;
ssl_certificate_key /home/ubuntu/certs/cert.key;
server_name example.com;
location = /favicon.ico {
access_log off;
log_not_found off;
}
location = /static/ {
root /home/ubuntu/example_project/app1;
}
location = / {
include proxy_params;
proxy_pass http://unix:/home/ubuntu/example_project/exampl_project.sock;
}
}
感谢您尝试解决我的问题。
【问题讨论】:
-
你需要显示你的nginx配置。
-
@DanielRoseman 用我的 nginx 配置更新了我的问题
标签: django nginx amazon-ec2 gunicorn