python - Flask redirect(url_for) error with gunricorn + nginx -


i having problem redirect(url_for) function in flask app.

any redirect(url_for("index")) line redirects application domain.com/app ip-addr/app, ip-addr own client machines ip, not server's.

this has gotten me confused, , don't know issue occurs, happens on server , not on local testing.

details:

i using reverse proxy setup found here http://flask.pocoo.org/snippets/35/. nginx config setup so

location /app {                 proxy_set_header x-script-name /app;                 proxy_set_header host $http_host;                 proxy_set_header x-forwarded-host $proxy_add_x_forwarded_for;                 proxy_redirect off;                 proxy_set_header x-real-ip $remote_addr;                 proxy_set_header x-scheme $scheme;                 proxy_connect_timeout 60;                 proxy_read_timeout 60;                 proxy_pass http://localhost:8000/;         } 

i have gunicorn running flask app upstart task. hints?

edit:

so dug around bit , found git report had similar issues, https://github.com/omab/django-social-auth/issues/157.

nginx - gunicorn serving nginx via localhost (127.0.0.1:1234). unfortunately, when authenticate social platforms, redirect url social-auth sending them 127.0.0.1:1234/twitter/complete, can't resolved client's browser.

it seems flask app not getting memo update redirect routes.

i found solution. had use redirect(url_for(location, _external=true)) redirects.

it seems url_for(x, _external=true) take variables in nginx proxy_set_header construct url, while url_for(x) not doing that.

this works both server , local development.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -