1234567891011121314151617181920212223242526272829303132333435363738394041 |
- # nginx配置文件
- # compose/nginx/nginx.conf
- upstream django {
- ip_hash;
- server web:8000; # Docker-compose web服务端口
- }
- # 配置http请求,80端口
- server {
- listen 80; # 监听80端口
- server_name 127.0.0.1; # 可以是nginx容器所在ip地址或127.0.0.1,不能写宿主机外网ip地址
- charset utf-8;
- client_max_body_size 10M; # 限制用户上传文件大小
- access_log /var/log/nginx/access.log main;
- error_log /var/log/nginx/error.log warn;
- location /static {
- alias /usr/share/nginx/html/static; # 静态资源路径
- }
- location /media {
- alias /usr/share/nginx/html/media; # 媒体资源,用户上传文件路径
- }
- location / {
- include /etc/nginx/uwsgi_params;
- uwsgi_pass django;
- uwsgi_read_timeout 600;
- uwsgi_connect_timeout 600;
- uwsgi_send_timeout 600;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_redirect off;
- proxy_set_header X-Real-IP $remote_addr;
- # proxy_pass http://django; # 使用uwsgi通信,而不是http,所以不使用proxy_pass。
- }
- }
|