Nginx proxy for an endpoint that redirect automatically to another path

Maxim Dounin mdounin at
Mon Nov 23 13:59:57 UTC 2020


On Mon, Nov 23, 2020 at 05:59:49AM -0500, meniem wrote:

> I'm trying to setup an Nginx proxy that redirect all requests from
> to (where
> is the server_name in nginx server)
> The configuration of server and location blocks are fine, but the issue is
> that the is automatically redirecting to
> (when I hit the
> from the browser, it's automatically taking me to
> which give an error with nginx proxy
> when trying to redirect to a non-existent page (
> redirect to -> which does not exist)
>         location /provider/ {
>         proxy_pass;
>         proxy_set_header X-Forwarded-Host $server_name;
>         proxy_set_header Host;
>         error_log /var/log/nginx/appname.log debug;
>         proxy_set_header Accept-Encoding text/xml;
> 	}
> So, how can I set this to redirect all requests from 
> automatically to 
> (we don't need to mention the full path in
> proxy_pass; as we have multiple endpoints to hi from the provider link such
> as api…etc.)

Check how redirects are returned, and configure proxy_redirect 
appropriately.  See for details.

Maxim Dounin

More information about the nginx mailing list