【问题标题】:nginx serving Django | 502 Bad Gatewaynginx 服务于 Django | 502错误的网关
【发布时间】:2014-05-22 15:46:16
【问题描述】:

我正在尝试提出一个大请求,如何使用 Django nginx 生成 pdf,这是我的 nginx.conf:

我觉得这个要求不高。

我可以做些什么来增加来自服务器的这个请求?

server {
    server_name .urbanarts.com.br;
    client_max_body_size 10M;
    client_body_timeout   10;
    client_header_timeout 10;
    keepalive_timeout     15;
    send_timeout          10;
    rewrite ^ https://urbanarts.com.br$request_uri? permanent;

    location /static {
        autoindex on;
        alias /srv/www/urbanarts/project/urbanarts_cloud/app/static;
        log_not_found   on;
    }

    location / {
        proxy_redirect      off;
        proxy_set_header    Host                    $host;
        proxy_set_header    X-Real-IP               $remote_addr;
        proxy_set_header    X-Forwarded-For         $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Protocol    $scheme;
        proxy_pass          http://127.0.0.1:8007/;
    }

    location /robots.txt {
        root            /srv/www/urbanarts/project/urbanarts_cloud/app/static;
        access_log      off;
        log_not_found   off;
    }

    location /favicon.ico {
        root             /srv/www/urbanarts/project/teste/urbanarts_cloud/static/images;
        access_log      off;
        log_not_found   off;
    }

}

谢谢..

【问题讨论】:

  • 您可以使用 celery 让请求启动一个后台进程,并在完成后返回给用户一个 URL。
  • 我认为您可能会将502 错误代码与413 混淆。这很可能与 PDF 文件的大小无关。

标签: python django nginx


【解决方案1】:

不要一直增加超时时间,从长远来看这对您没有帮助。

改为使用celerypython-rq 将长时间运行的任务发送到后台并立即返回响应。

【讨论】:

    猜你喜欢
    • 2011-02-06
    • 2020-09-29
    • 2012-07-16
    • 2012-05-28
    • 2018-12-05
    • 1970-01-01
    • 2017-07-07
    • 2020-04-05
    • 2019-01-01
    相关资源
    最近更新 更多