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:


Instead of


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




3 Answers 3


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]
  • ...and this would be the "clever use of mod_rewrite" I mentioned :-)
    – voretaq7
    Feb 3, 2010 at 7:23
  • Excellent, this is what I needed. Thanks very much to both of you.
    – Andrew
    Feb 3, 2010 at 7:27

DNS can't help you here: The only ports it knows about are its own (53) and the ones encoded in SRV records.

If I remember correctly Tomcat allows you to set up name-based virtual hosts, which is what it sounds like you want (stick your apps in different named vhosts rather than on different ports).

Moving your "port 8080" app to port 80 on another IP is also an option.

If you need to keep the app on port 8080 for some reason clever use of mod_rewrite or HTTP/301 redirects can be made to do what you want ("If the host is "example2" redirect the user to port 8080"). Deeper levels of complexity are left as a (painful) exercise for the reader.


You should also be able to solve this at the firewall level using two NAT rules, assuming the websites can be bound to seperate IPs. You NAT one of the websites through from external port 80 to internal port 8080.

As an aside, I prefer a port other than 8080, as that's conventionally used for Web Proxies.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy