soooo close: nginx gunicorn flask directory stripped from links

Francis Daly francis at
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
> 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 apply in your case?

That page links to a 404 page, where the original content appears to be at

You can possibly / potentially avoid all of that, if you are happy
to deploy your app at instead of at -- 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,

Francis Daly        francis at

More information about the nginx mailing list