Good day.
I trying to use Nginx as a reverse proxy in front of two Tomcat instances. Each Tomcat instance is serving up different sites, but I want them on the same domain e.g:
Site 1: localhost/site1 (served by tomcat 1, on port 9090)
Site 2: localhost/site2 (served by tomcat 2, on port 9190)
My conf is like this:
[code]
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location /site1/ {
proxy_pass http://localhost:9090/;
}
location /site2/ {
proxy_pass http://localhost:9190/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root share/nginx/html;
}
}
}
[/code]
An initial request to say localhost/site1/index works fine, but tomcat1 is not adding site1 to urls, so links are appearing as localhost/link1, as opposed to localhost/site1/link1
Could rewrites be the solution? I tried various rewrites, but none seemed to give the solution I needed.
I am not totally confident that this is not a tomcat config problem, but as I am running the app as a tomcat ROOT app, I would have thought the config for prepending site1 to links might lie with Nginx.
Any help is greatly appreciated.
Cheers
Stu