I am trying to deploy two instances of a Vaadin Spring application using nginx to redirect requests to the appropriate instance.
The first server should be available at www.example.org/
, the second one at www.example.org/second/
, both at port 80. The first server listens to port 9002, the second to port 9003.
My nginx configuration looks like this:
server_name www.example.org localhost;
root /;
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
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_cookie_path ~*^/.* /;
proxy_pass http://127.0.0.1:9002/;
proxy_redirect off;
}
location /second/ {
proxy_set_header X-Forwarded-Host $host/second;
proxy_set_header X-Forwarded-Server $host/second;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host/second;
proxy_cookie_path ~*^/.* /;
proxy_pass http://127.0.0.1:9003/;
proxy_redirect off;
}
}
The first server works completely fine.
I can also access the second server; requests to any of its URLs correctly redirect me to its login page. As soon as i click a button, i get a session expired message. From the nginx access logs, it looks like the button click triggers a POST request which goes to /vaadinServlet/UIDL/?v-uiId=0
and returns code 200 (OK).
I believe the request should really go to /second/vaadinServlet/UIDL/?v-uiId=0
. Thus, i am stuck on the login page.
Am i correct in my assumption that the vaadinServlet request goes to the wrong URL? If so, how do i get it to go to the correct one?
I am thinking of using nginx to extract the necessary information from the referral URL but i believe it should be possible to configure Vaadin/Spring to handle this case.