Wednesday 15 January 2014

Using Django, switched from heroku + gunicorn to digitalocean + nginx + gunicorn, site now broken -



Using Django, switched from heroku + gunicorn to digitalocean + nginx + gunicorn, site now broken -

i had django app on heroku while no problems. want move digital ocean droplet, partly learning exercise, partly scalability (and cost) reasons.

after next this first-class tutorial letter, app working huge gotcha: infinite redirect loop when seek log in admin site. first request post ?next=/admin/ username , password, gets 302 response redirect /admin/, gets 302 response redirect ?next=/admin/, , on.

i have spent 2 or 3 hours google , various nginx tutorials , first time "google error message, re-create , paste random code snippets, repeat" algorithm has ever failed me, i'm hoping reason error trivial solve , can't see it?

if it's not trivial solve, allow me know , i'll post more info.

thanks in advance

edit 1: nginx config file app verbatim re-create of tutorial. looks this:

upstream hello_app_server { # fail_timeout=0 means retry upstream if failed # homecoming http response (in case unicorn master nukes # single worker timing out). server unix:/webapps/hello_django/run/gunicorn.sock fail_timeout=0; } server { hear 80; server_name example.com; client_max_body_size 4g; access_log /webapps/hello_django/logs/nginx-access.log; error_log /webapps/hello_django/logs/nginx-error.log; location /static/ { alias /webapps/hello_django/static/; } location /media/ { alias /webapps/hello_django/media/; } location / { # http header of import plenty have own wikipedia entry: # http://en.wikipedia.org/wiki/x-forwarded-for proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; # enable if , if utilize https, helps rack # set proper protocol doing redirects: # proxy_set_header x-forwarded-proto https; # pass host: header client right along redirects # can set within rack application proxy_set_header host $http_host; # don't want nginx trying clever # redirects, set host: header above already. proxy_redirect off; # set "proxy_buffering off" *only* rainbows! when doing # comet/long-poll stuff. it's safe set if you're # using serving fast clients unicorn + nginx. # otherwise _want_ nginx buffer responses slow # clients, really. # proxy_buffering off; # seek serve static files nginx, no point in making # *application* server unicorn/rainbows! serve static files. if (!-f $request_filename) { proxy_pass http://hello_app_server; break; } } # error pages error_page 500 502 503 504 /500.html; location = /500.html { root /webapps/hello_django/static/; } }

django nginx gunicorn http-status-code-302

No comments:

Post a Comment