我正在使用Django REST框架构建一个API,该框架由Gunicorn和Nginx提供.项目"exampleproject"必须在以下子路径上运行:https://100.100.100.100/exampleproject (示例IP地址).我没有为IP注册的域名.
目前,起始页面按预期在https://100.100.100.100/exampleproject上呈现.但是,"产品"的资源路径不起作用.而不是https://100.100.100.100/exampleproject/products,起始页面显示https://100.100.100.100/products - 这不起作用.
我为exampleprojectin 配置了子路径/etc/nginx/sites-enabled/default如下:
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;
}
Run Code Online (Sandbox Code Playgroud)
当我手动访问https://100.100.100.100/exampleproject/products时, Nginx会记录以下内容/var/log/nginx/access.log:
"GET/products/HTTP/1.1"404 151" - "