I have a web server on my LAN with the URL https://10.0.0.22
and I am trying to access it from the internet through an nginx reverse proxy with a URL like https://domain.com/my/web/app
.
The difficulty I'm having is that the local server sends a 302 redirect to /login.php
, which nginx then passes back to the external client's browser to become https://domain.com/login.php
instead of https://domain.com/my/web/app/login.php
. This results in a 404 error because there's nothing at https://domain.com/login.php
.
I have tried many different options with little success, including a wide range of rewrite
, proxy_redirect
, and proxy_buffering
directives, but this is as close as I can get it:
location ^~ /my/web/app/
{
proxy_buffering off;
rewrite /my/web/app/(.*) /$1 break;
proxy_pass https://10.0.0.22/;
}
Is there a way to configure nginx so that the internal web server's 302 redirect to /login.php
manifests externally as /my/web/app/login.php
?