Reputation: 1070
I have a post server listening on port 8081 and sample path. I want to be able to redirect the entire URI query param the the node service. How should i do it.
for example i want the following post request url http://exmaple.com/foo/bar?bla=1 to passed to http://example.com:8081/foo/bar?bla=1
It looks very simple and straight forward example but just can't get it working, any ide?
location ^~ /foo/bar {
rewrite_log on;
rewrite ^/foo/bar(.*) /$1 break;
proxy_pass http://example.com:8081/foo/bar;
}
Upvotes: 3
Views: 5734
Reputation: 49792
By default proxy_pass
will not change the request URI (including the query string). The example in your question illustrates two ways in which the URI can be changed prior to being sent upstream - by appending an optional URI to the proxy_pass
statement (see this document) or with a rewrite...break
statement (see this document).
If you remove both, the URI will be sent upstream unmolested and with the query string intact:
location ^~ /foo/bar {
proxy_pass http://example.com:8081;
}
Upvotes: 5