Reverse proxy to a tomcat service (folder name)

kheraud nginx-forum at nginx.us
Fri May 27 18:59:41 MSD 2011


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 ?

Thanks a lot

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,201561,201561#msg-201561




More information about the nginx mailing list