0

it is possible to rewrite a url and use a proxy server for backgound connection?

An example, I want to use this URL my.domain.org/demo on my proxy server and redirect this into the root directory of my tomcat on another server with proxy_pass my.tomcat.local.

The url must be place my.domain.org/demo and must used the proxy url my.tomcat.local (without any subdomains). Is this hook possible?

Thanks !!!!

luk3
  • 141
  • 1
  • 1
  • 6

1 Answers1

0

Yes, this is absolutely possible.

Use the following configuration

location /demo {
    proxy_pass http://my.tomcat.local/; #Pay attention to the trailing slash. It MUST be present here.
}

The point is that if the specified proxy_pass destination contains path (a single slash is also considered as a path), then Nginx will directly pass request to that URL; otherwise, Nginx will append the path of the received URL to the proxy_pass destination and use the resulting URL.

Reference: http://wiki.nginx.org/HttpProxyModule#proxy_pass

leolong
  • 172
  • 1
  • 6
  • Thanks, with this configuration it will be works. I had configured this before with an upstream, like this... `upstream demo { server 172.16.14.37:8081 fail_timeout=0; } location /demo { proxy_pass http://demo; } ` ... but this doesnt work. Why? – luk3 Feb 14 '14 at 10:21