0

I have two website running in two different two Tomcat servers on one machine. One Tomcat is listening in 80 port and other on 8080.

Requirements is, I want to access both of these website without appending the port. For eg:

  1. Site A http://www.siteA.com (Tomcat 1: Port 80)

  2. Site B http://www.siteB.com (Tomcat 2: Port 8080),

Currently Site B is accessible via http://www.siteB.com:8080. What are the possible options so I can access the website B without appending port 8080 (i.e http://www.siteB.com) and without Domain Forward and Marking, I am considering the following:

  1. Proxy Server
  2. Router

Please share some pointer that could helpful. Thank you.

Kamran

Kamran
  • 21
  • 2

2 Answers2

0

I believe this is a nice use case for a reverse proxy.
This answer is a good starting point to help you setup from your requirements, using NGINX: https://stackoverflow.com/a/13241047/967410

Applied to your case, it would be something like this:

server { 
  server_name www.siteA.com;

  # siteA reverse proxy follow
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_pass $scheme://x.x.x.x:80;
}

server { 
  server_name www.siteB.com;

  # siteB reverse proxy settings follow
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_pass http://x.x.x.x:8080;
}
Community
  • 1
  • 1
Dimitri Hautot
  • 438
  • 5
  • 12
0

Why not run httpd on port 80 and use mod_rewrite to forward the request?

It seems in this case all you really care about is the hostname, anyway.

Obviously you would have the two tomcat instances on a port other than 80 in this case.

Eric Wilk
  • 59
  • 2