Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

'Redirect' POST request when path to the service changes

$
0
0
Hey guys,

I'm not an expert on NGINX and am struggling with the redirection (if we can call it this way) of POST requests.
The thing is a service changed from, let's say, 'https://ip-address/app-label/rest/my-operation' to 'https://ip-address/new-app-label/rest/my-operation'
As you can see, the identification of the app changed and the rest of the URI is preserved.

To the old path, I used to have a NGINX location (the rule uses a regex, ^/app-label(/.*)$) and I only changed that to use the 'new-app-label' instead. It works.
But, at least temporarily, I need to keep the old path working (there are clients around using it).
So, my idea was to create another location still using the old label, and 'forwarding' the requests to the new location (preserving, naturally, the POST data).

In the beginning, I tried duplicating the location and playing with both labels, and both locations were pointing (and I'm using proxy_pass here) to the same upstream (the application properly said, in practical terms). But, because the app label (a.k.a. context path) changed, I also had to change the app context in the app setup. So, I believe I need to, somehow, modify (rewrite) the original request, replacing the old 'context path' by the new one, yet preserving the POST data, before I actually use proxy_pass to send it to the application. Makes sense to you? If it does, how'd you do it? I tried many combinations, but couldn't make it work yet.

If more info is required to clarify the issue, let me know. I hope I was able to explain the scenario.

Thanks so much for any help, in advance.

Cheers,
Pedro

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>