Forwarding to upstream server at port specified in url query paramter
dakun
nginx-forum at nginx.us
Wed Mar 6 00:51:47 UTC 2013
I am trying to use the HttpProxyModule to forward traffic to an upstream
server. The incoming request will be like:
http://foobar.com/path?p=1234
where p=1234 indicates the upstream port to use.
For this example I would want to forward to http://upstreamserver.com:1234.
How can I achieve this?
I have experimented with regex and rewrites but was unsuccessful mainly
because regex on "location" directive does not apply to url parameters. And
rewrites do not allow me to change the outgoing port number.
I had also tried to use
if ($args ~ "p=(\d+)") {
set $port $1;
rewrite ^ ??????
}
But I ended up with either a browser redirect which is not desirable, or I
ended up sending traffic to local file which does not exist.
Unfortunately I cannot change the incoming request to include '1234' as part
of path, e.g. http://foobar.com/p/1234/. I have no control of that.
I am using nginx 1.3.13 with websocket support.
Thanks in advance for any help.
Dakun
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,236969,236969#msg-236969
More information about the nginx
mailing list