Welcome! Log In Create A New Profile

Advanced

Forwarding to upstream server at port specified in url query paramter

March 05, 2013 07:51PM
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
SubjectAuthorPosted

Forwarding to upstream server at port specified in url query paramter

dakunMarch 05, 2013 07:51PM

Re: Forwarding to upstream server at port specified in url query paramter

Jonathan MatthewsMarch 05, 2013 08:20PM

Re: Forwarding to upstream server at port specified in url query paramter

dakunMarch 06, 2013 02:04AM

Re: Forwarding to upstream server at port specified in url query paramter

Jonathan MatthewsMarch 06, 2013 04:56AM

Re: Forwarding to upstream server at port specified in url query paramter

dakunMarch 06, 2013 01:36PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 86
Record Number of Users: 3 on November 23, 2014
Record Number of Guests: 377 on November 23, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready