Django和uwsgi仅在特定网址上显示502,

时间:2018-06-26 15:22:48

标签: python django uwsgi

我最近将Django升级到1.8,将Celery升级到4.1.1。升级后,仅一个网址在服务器上出现502错误。

我正在使用uwsgi。这是一些代码。我遇到问题的网址是judging/

urlpatterns = patterns('lbb.views',
    url(r'^judging/', include('judging.urls')),
)

判断应用程序中的urls.py

urlpatterns = patterns('judging.views',
    url(r'^$', AppView.as_view(), name='judge_home')
)

视图是

class AppView(TemplateView):
    template_name = 'judging/app.html'

    def get(self, request, *args, **kwargs):
        """ method get of class JudgeLoginView """
        if not request.user.is_authenticated():
            url="%s?next=%s" % (reverse("judge_login"), '/judging/#/judge_home')
            return redirect(url)
        return super(AppView, self).get(self, request, *args, **kwargs)

用于正常运行。但是升级后我遇到了这个问题。 Nginx文件是

upstream application {
    server lbb-app:8000;
}


server {
    listen 80 default_server;

    charset     utf-8;

    client_max_body_size 4G;   # adjust to taste
    server_tokens off;

    add_header X-Content-Type-Options nosniff;

    add_header X-XSS-Protection "1; mode=block";

    add_header Cache-Control "no-store";

    add_header Pragma "no-cache";

    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";


    location /work {
        include     uwsgi_params;
        uwsgi_pass  application;
    }


    location / {
        include     uwsgi_params;
        uwsgi_pass  application;
    }
}

uwsgu.ini是

[uwsgi]
env=DJANGO_SETTINGS_MODULE=lbb.settings.common
chdir=/opt/webapp
module=lbb.wsgi:application
reload-mercy=10
master=1
no-orphans=1
workers=4
enable-threads=1
single-interpreter=1
socket=:8000
harakiri=20
max-requests=5000
vacuum=1
buffer-size = 65535

我在nginx配置中做了一些更改,并部署了两次。但是又变回原来的位置并重新部署。其他所有网址都可以正常运行。除了我提到的https://website/judging/。我尝试注释一些不必要的代码。但这仍然行不通。

1 个答案:

答案 0 :(得分:2)

我认为有问题:

urlpatterns = patterns('judging.views',
    url(r'^$', AppView.as_view(), name='judge_home')
)

您应该从网址格式中删除$或^符号。