Reverse proxy to a tomcat service (folder name)
Igor Sysoev
igor at sysoev.ru
Fri May 27 19:11:08 MSD 2011
On Fri, May 27, 2011 at 10:59:41AM -0400, kheraud wrote:
> Hello,
>
> I am breaking my head against the wall since his morning on this issue
> maybe you can help me.
>
> I have a single physical server hosting tomcat WARs and also other
> standalone services. I use subdomains and Nginx to route to the
> requested service.
> Tomcat append to URIs the name of the deployed WAR. For example, if I
> deploy myApp.war on my tomcat server, I can access it through
> http://mydomain.com:8080/myApp/.
> What I want is to acces my service through http://myApp.domain.com and
> navigate my service AND whitout having http://myApp.domain.com/myApp/ !
>
> I wrote this conf :
>
> server {
> server_name myapp.domain.com;
> root /var/lib/tomcat7/webapps/myapp;
> access_log /var/log/nginx/myapp.domain.com_access.log;
> error_log /var/log/nginx/myapp.domain.com_error.log;
>
> location / {
> proxy_pass http://localhost:8080/myapp;
> proxy_redirect off;
> proxy_set_header Host $host;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For
> $proxy_add_x_forwarded_for;
> }
>
> location /myapp {
> proxy_pass http://localhost:8080/myapp;
> proxy_redirect off;
> proxy_set_header Host $host;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For
> $proxy_add_x_forwarded_for;
> }
> }
>
> If I access http://myapp.domain.com/, my browser rewrites this url to
> http://myapp.domain.com/myapp/. I would like to avoid the /myapp/
> repeated.
>
> Do you have hints or comments to help me ?
Probably this:
location / {
proxy_pass http://myapp.domain.com:8080/myapp/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
sub_filter /myapp/ /;
}
--
Igor Sysoev
More information about the nginx
mailing list