Forwarding to upstream server at port specified in url query paramter
Jonathan Matthews
contact at jpluscplusm.com
Wed Mar 6 09:54:02 UTC 2013
On 6 March 2013 07:04, dakun <nginx-forum at nginx.us> wrote:
> Thanks for the advice on $arg_PARAMETER. It allows me to retrieve the
> parameter. However I am not able to use it as a port number for proxy_pass.
>
> This shows that I can get the parameter and use it in rewrite:
> location /test {
> rewrite ^ http://www.google.com/?q=$arg_p;
> }
>
> This does not work. Got error "no resolver defined to resolve
> www.google.com" in log.
> location /path {
> proxy_pass http://www.google.com/?q=$arg_p;
> }
Come on chap - try a bit harder!
http://bit.ly/12tikWj
> This shows that I can use the parameter in a rewrite prior to proxy_pass:
> location /path {
> rewrite ^(.*)$ /?q=$arg_p break;
> proxy_pass http://www.google.com/;
> }
>
> Unfortunately I still can't use the paramrter value as an upstream port
> number:
> location /path2 {
> rewrite ^(.*)$ :$arg_p break;
> proxy_pass http://www.google.com;
> }
No, you just haven't configured it correctly.
You really need to read the proxy_pass and rewrite documentation more carefully.
Neither works exactly the way you seem to think they do.
Jonathan
--
Jonathan Matthews // Oxford, London, UK
http://www.jpluscplusm.com/contact.html
More information about the nginx
mailing list