Welcome! Log In Create A New Profile

Advanced

Multiple proxies on one server

Posted by stuartrexking 
Multiple proxies on one server
February 13, 2010 07:52AM
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
Re: Multiple proxies on one server
February 15, 2010 08:44PM
I found a solution, which involved adding config to the server.xml in each of the Tomcat instances. If the application is running in the ROOT path then add this Context entry within the Host section of the server.xml

[code]
<Context path="/site1" docBase="ROOT" debug="0" reloadable="true" cachingAllowed="false" allowLinking="true" />
[/code]

Hope that helps anyone else with a similar problem.

Stu



Edited 1 time(s). Last edit at 02/15/2010 08:46PM by stuartrexking.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 159
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready