Nginx重定向到Docker中Django应用程序的Sphinx文档
我已将Sphinx文档添加到Django项目中,并希望从Nginx重定向到Docker中Django应用程序的Sphinx文档,django,nginx,docker-compose,python-sphinx,nginx-location,Django,Nginx,Docker Compose,Python Sphinx,Nginx Location,我已将Sphinx文档添加到Django项目中,并希望从/docsuri中提供生成的Sphinx页面,但我似乎无法将uri和目录对齐以提供正确的内容。我尝试了许多配置。目前的一个包括在下面 Django站点服务正常(虽然还没有设置静态文件——我想我也会遇到同样的问题!)。但是/docs从nginx返回404 我尝试了root与alias以及不同的路径设置。我已经验证了该卷在/docs上加载正常,因此index.html存在,但没有乐趣 欢迎大家提出建议 docker compose.yml ve
/docs
uri中提供生成的Sphinx页面,但我似乎无法将uri和目录对齐以提供正确的内容。我尝试了许多配置。目前的一个包括在下面
Django站点服务正常(虽然还没有设置静态文件——我想我也会遇到同样的问题!)。但是/docs
从nginx返回404
我尝试了root
与alias
以及不同的路径设置。我已经验证了该卷在/docs
上加载正常,因此index.html
存在,但没有乐趣
欢迎大家提出建议
docker compose.yml
version: '3.8'
services:
nginx:
image: nginx
ports:
- 443:443
- 80:80
volumes:
- ./config/nginx:/etc/nginx/conf.d
- ./static:/static
- ./src/docs/build/html:/docs
depends_on:
- web
web:
container_name: inventory
build:
context: .
dockerfile: Dockerfile.dev
env_file: .env
volumes:
- ./src:/inventory
- ./config/nginx/certs:/etc/certs
expose:
- 443
environment:
- DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE}
command: >
<Does stuff & runs gunicorn>
upstream web {
ip_hash;
server web:443;
}
# Redirect all HTTP requests to HTTPS
server {
listen 80;
server_name localhost;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name localhost;
# Serve up the Sphinx docs directly
location /docs {
# root /docs;
try_files $uri $uri.html $uri/ index.html;
}
# Pass request to the web container
location / {
proxy_pass https://web/;
}
# SSL properties
# (http://nginx.org/en/docs/http/configuring_https_servers.html)
ssl_certificate /etc/nginx/conf.d/certs/localhost.crt;
ssl_certificate_key /etc/nginx/conf.d/certs/localhost.key;
root /usr/share/nginx/html;
add_header Strict-Transport-Security "max-age=31536000" always;
}