我已经通过以前的一些线程去服务Django的一个子目录: How do I set subdirectory in nginx with Django how to deploy django under a suburl behind nginx Serving flask app on subdirectory nginx + uwsginginx的通过uWSGI
的基本教训是,你应该只需要配置您的网站(可用)来实现这个。现在我已经试过
server {
listen 80;
server_name www.example.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /path/to/project;
}
location /project/ {
root /path/to/project;
include /etc/nginx/uwsgi_params;
uwsgi_param SCRIPT_NAME /project;
uwsgi_modifier1 30;
uwsgi_param PATH_INFO "$1";
uwsgi_pass unix:/tmp/project.sock;
}}
一切的各种排列运行完美,当我定义的位置是“/”(并删除SCRIPT_NAME,modifier1,PATH_INFO和根本无所谓。但是试图用一个子目录总是导致找不到网页(404):?
Request URL: http://www.example.com/project/project
(编辑),它增加了目录的要求什么我不搞清楚
(试过forced_script_name - should't必须使用这个并给出其他头痛类型 - 和uwsgi配置设置)
编辑:
location /project/ {
root /path/to/project;
include /etc/nginx/uwsgi_params;
uwsgi_param SCRIPT_NAME /project;
uwsgi_pass unix:/tmp/project.sock;
}
不工作...套接字是存在的,当我配置/工程 - 我看不出我错过了什么。
UPDATE:
location ~ /project(?<path_info>/.*|$) {
include /etc/nginx/uwsgi_params;
uwsgi_pass unix:/tmp/project.sock;
uwsgi_param PATH_INFO $path_info;
uwsgi_param SCRIPT_NAME /project;
}
这将加载了网站,但所有的链接指向http://example.com/link/to/something而不是http://example.com/project/link/to/something
django 1.9.2,uwsgi 2.07-debian (在ubuntu 15.10服务器上运行) – Bjorn