Django and uwsgi shows 502 on production only for specific URLs


Django and uwsgi shows 502 on production only for specific URLs



I recently upgraded Django to 1.8 and Celery to 4.1.1. After the upgrade, I am getting 502 error on server for only one url.



I am using uwsgi. Here is some of the code. The URL I am getting problem with is judging/


uwsgi


judging/


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



urls.py in judging app


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



the view is


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)



It use to run normally. But after the upgrade I getting this problem. The nginx file is


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;
}
}



The uwsgu.ini is


[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



I made some changes in nginx config and deployed couple of times. But changed back to old one and redeployed. Every other URL works fine. Except the one I mentioned https://website/judging/. I tried commenting some unnecessary code. But it still doesn't work.


https://website/judging/





Something things to try: Change the get() to return a simple HttpResponse. Add a dollar to the url.py url(r'^judging/$', include('judging.urls')). Also try going to the url with and without the trailing /.
– Splatmistro
Jun 26 at 15:30



get()


url(r'^judging/$', include('judging.urls'))


/





Note we prefer a technical style of writing here. We gently discourage greetings, hope-you-can-helps, thanks, advance thanks, notes of appreciation, regards, kind regards, signatures, please-can-you-helps, chatty material and abbreviated txtspk, pleading, how long you've been stuck, voting advice, meta commentary, etc. Just explain your problem, and show what you've tried, what you expected, and what actually happened.
– halfer
Jul 1 at 10:44




1 Answer
1



I think there is the problem:


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



You should delete $ or ^ sign from url pattern.





Thanks. But I don't think that is the problem. docs.djangoproject.com/en/1.8/topics/http/urls/#id4 . But I will try. Sometimes documentation doesn't reflect the code.
– saiyan
Jun 27 at 5:16





You were right. Removing ^ solved the problem. Documentation doesn't reflect the same though. Thanks a lot.
– saiyan
Jun 27 at 6:23






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to add background colour in existing image using Swift?

Moria Casán

How to make file upload 'Required' in Contact Form 7?