Welcome! Log In Create A New Profile


Proxy_Pass variable not truncating URL

Posted by SeanBez 
Proxy_Pass variable not truncating URL
July 15, 2019 10:26AM
Hi all. I'm relatively new to NGINX as a reverse proxy and have run into a known issue with an unknown solution and need help please.

Currently we have an app that posts to domain.com/liveness and proxy_pass redirects this to an external 3rd party but it only passes through the data from the app after /liveness.

The 3rd party had a failover event on the weekend and as DNS is only reloaded when the config is reloaded, we had an outage on our side as well.

So now I've been tasked with setting up proxy_pass as a variable which I have added to the config. This means every time the variable is referenced it does a DNS lookup (to known internal resolved not on the local host) and it's working.

However the whole url is not passed through eg domain.com/liveness/api/xxx

I'm not an experienced coded so while a rewrite seems the correct way to do this I am baffled by the regex and associated $ variables to get the output sent to proxy_pass part to drop liveness.

Any help would be greatly appreciated. Thanks
Re: Proxy_Pass variable not truncating URL
July 15, 2019 11:58AM
UPDATE: This is the config I've added and the important part is working. But I've broken my monitoring.

By default if the website is opened with /live and no other data it should open a homepage on the 3rd party (for my monitoring platform) but it is now broken. I assume because there is nothing to pass as the URL is /live with nothing after. Do I need another IF to cover the "blank" URL?


if ($request_uri ~* "/live/(.*)"){

set $variable server.domain.com;

proxy_pass https://$variable/$1;
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 74
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready