Directing DNS to Different Ports – Configuration Guide

domain-name-systemporttomcat

Greetings all,

I have a server with two tomcat services (one being run on port 80, the other 8080).

What I'm wanting to achieve is to have two different DNS records for these two ports, so they'll be accessible via:

http://example1/
http://example2/

Instead of

http://example1/
http://example1:8080/

I know this isn't possible using DNS A records, but does anyone know of another solution I could look into?

Thanks,

Andrew

Best Answer

you can't do that on DNS level.

what you can do is have your server1 (port 80) record as it is, then create server2 record (you can use same IP) and have http redirect to server1:8080 (you can do this with apache rewrite):

<VirtualHost IP:80>
ServerName server2
RewriteEngine on
RewriteRule ^(.*)$ http://server1:8080/ [R,L]
</VirtualHost>