I need to configure Nginx as a reverse proxy for Tomcat. The problem is when I try to access the web application through a subdomain (myapp.domain.com), in this case is displayed Tomcat webapps root, not myapp.
Nginx conf
server {
listen 80;
root /usr/share/tomcat/webapps/myapp;
index index.php index.html index.htm;
access_log off;
server_name myapp.domain.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8181;
}
}
I tried adding this line in Tomcat's server.xml, inside the Host tag:
<Context path="" docBase="myapp" debug="0" reloadable="true" />
but in this way myapp became the default one and is "always" loaded, even if trying to access webapps root