Two Domains, One Apache Server. One Tomcat Server. How do I configure Apache to redirect one doamin to Tomcat?

Viewed 16

I have two domains domainA.com and domainB.com that both point to the same IP address/server. On that server...

  • I have an Apache2 web server serving port 80
  • I have a TomCat9 serving port 8080

I want to redirect all requests (including "/") to the default port 80 of domainB.com to the TomCat9 server on port 8080, whilst leaving all traffic to domainA.com to be handled by the Apache2 web server.

Can anyone recommend a simple recipe for achieving this?

I have looked at https://tomcat.apache.org/tomcat-4.1-doc/proxy-howto.html but got somewhat lost.

1 Answers

May have been easier than I had expected.

I just added the following to /etc/apache2/sites-enabled/donainB.conf

<VirtualHost *:80>
    ServerAdmin michael.ellis@myemail
    ServerName  domainB.com
    ProxyPass / http://localhost:8080/
</VirtualHost>

I have no idea if this is the correct thing to do, but it seems to be doing the job.

Related