Possible Duplicate:
How to use DNS to redirect domain to specific port on my web server

I have a fedora core 6 box with independent IP address, I have apache installed as default 80 port, I will install lighttpd as 8080 or some other port.

Is there possible i can set DNS so a coming http://mydomainname.com will go to ligthttp server not default apache web server with 80 port? (apache 80 port is serving a few other sites, I just like one of site forwarding to lighttpd 8080 port)



5 Answers 5


DNS is not aware of port numbers. All DNS does is map a hostname to an IP address.

The easiest thing to do would be to get another IP address from your ISP or hosting provider and run lighttpd on it separately. You can add multiple IP address on the same interface as well so you will not have to add an additional network card.

Or you could go another route and have Apache proxy requests for you on to the lighthttp server. Check out the apache proxy module.

Hope this helps.

  • You dont need to have a second IP to do this. All you'd need to do is setup port forwarding on the router on 8080 to the same server IP and have lighthttpd listen on 8080.
    – barfoon
    Aug 26, 2009 at 17:48
  • barfoon you are correct assuming he has a router in front of this box. I was assuming he was directly on the internet with this server. Port forwarding at the router level would certainly work as well.
    – jchawk
    Aug 26, 2009 at 18:03

DNS and port assignments have nothing to do with each other, so you can't use DNS to do what you want. All port 80 traffic will hit the Apache http server, so the redirection you want must happen within Apache. Jakub's answer should work for you.


Even tho this is not the place for this type of question, googling reveals this as a solution:

run lighttpd on a separate port for the second domain.
Use mod_proxy in Apache to redirect traffic for the second domain to lighttpd.



Jim's and Jakub's answers are correct. DNS simply maps a domain name (example.com) to an IP address. It is your browser that chooses the port.

There is another solution however. If you have a fancy router that can do hostname based forwarding, you maybe able to 'translate' External Port 80 to Internal Port 8080 if the host name matches example.com. This is assuming that you still want Apache on Port 80 to be accessible from a different domain.


In a parallel universe, the plan to use SRV records to identify web servers for a domain was accepted and popularised, which would have made this problem much more solvable. Sadly, however, it was never accepted by the IETF, and no major clients that I am aware of implement this.

Not the answer you're looking for? Browse other questions tagged or ask your own question.