nginx.conf 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # nginx配置文件
  2. # compose/nginx/nginx.conf
  3. upstream django {
  4. ip_hash;
  5. server web:8000; # Docker-compose web服务端口
  6. }
  7. # 配置http请求,80端口
  8. server {
  9. listen 80; # 监听80端口
  10. server_name 127.0.0.1; # 可以是nginx容器所在ip地址或127.0.0.1,不能写宿主机外网ip地址
  11. charset utf-8;
  12. client_max_body_size 10M; # 限制用户上传文件大小
  13. access_log /var/log/nginx/access.log main;
  14. error_log /var/log/nginx/error.log warn;
  15. location /static {
  16. alias /usr/share/nginx/html/static; # 静态资源路径
  17. }
  18. location /media {
  19. alias /usr/share/nginx/html/media; # 媒体资源,用户上传文件路径
  20. }
  21. location / {
  22. include /etc/nginx/uwsgi_params;
  23. uwsgi_pass django;
  24. uwsgi_read_timeout 600;
  25. uwsgi_connect_timeout 600;
  26. uwsgi_send_timeout 600;
  27. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  28. proxy_redirect off;
  29. proxy_set_header X-Real-IP $remote_addr;
  30. # proxy_pass http://django; # 使用uwsgi通信,而不是http,所以不使用proxy_pass。
  31. }
  32. }