【发布时间】:2015-03-24 17:39:39
【问题描述】:
我正在使用 Django REST framework 构建一个 API,它通过 Gunicorn 和 Nginx 提供服务。项目“exampleproject”必须在子路径中运行,例如:https://100.100.100.100/exampleproject(示例 IP 地址)。我没有为该 IP 注册的域名。
目前,起始页在https://100.100.100.100/exampleproject 处按预期呈现。但是,“产品”的资源路径不起作用。起始页显示 https://100.100.100.100/products 而不是 https://100.100.100.100/exampleproject/products - 这不起作用。
我在/etc/nginx/sites-enabled/default中配置了exampleproject的子路径如下:
server {
# ...
location /exampleproject/ {
proxy_pass http://localhost:8007/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
当我手动访问https://100.100.100.100/exampleproject/products时,Nginx在/var/log/nginx/access.log中记录如下:
"GET /products/ HTTP/1.1" 404 151 "-"
【问题讨论】:
标签: django nginx django-rest-framework gunicorn