Welcome! Log In Create A New Profile

Advanced

Re: Reverse proxy to a tomcat service (folder name)

May 27, 2011 11:12AM
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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Reverse proxy to a tomcat service (folder name)

kheraud May 27, 2011 10:59AM

Re: Reverse proxy to a tomcat service (folder name)

Igor Sysoev May 27, 2011 11:12AM

Re: Reverse proxy to a tomcat service (folder name)

kheraud May 27, 2011 12:26PM

Re: Reverse proxy to a tomcat service (folder name)

Igor Sysoev May 27, 2011 12:34PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 162
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready