soooo close: nginx gunicorn flask directory stripped from links

Francis Daly francis at daoine.org
Fri Sep 16 07:48:28 UTC 2022


On Fri, Sep 16, 2022 at 01:22:46AM -0600, Brian Carey wrote:

Hi there,

> I'm very close to getting my flask app properly reverse-proxied by nginx.

If your nginx config is correct, then it might be that the upstream
/ backend service (the flask app, in this case) does not like being
reverse-proxied (to a different "sub-directory"),

> I can access and use my app successfully at http://127.0.0.1:8000.
> 
> I can get to my main page at http://my.domain/app. If I specifically enter
> the url of a sub-directory/page I can get there, for example
> http://my.domain/app works and http://my.domain/app/home works.

> Hovering over the link it points to http://my.domain/home instead of
> http://my.domain/app/home.

Does https://pypi.org/project/flask-reverse-proxy-fix/ apply in your case?

That page links to a 404 page, where the original content appears to be at
https://web.archive.org/web/20131129080707/http://flask.pocoo.org/snippets/35/

You can possibly / potentially avoid all of that, if you are happy
to deploy your app at http://127.0.0.1:8000/app/ instead of at
http://127.0.0.1:8000/ -- in that case, all of the "local" links will
be the same in both the direct and reverse-proxied cases, so only the
hostname/port would need adjusting. (Which is usually more straightforward.)

(I'm presuming that it is possible to deploy a flask app somewhere other
than the root of the web service.)

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list