Skip to main content

How to redirect multiple domain to same ip but different port for different services [Resolved]

This question already has an answer here:

In my VM, i'm running both apache2 and nginx, but apache2 is pointed to Port 8080 and nginx is Port 80. Already i pointed my domain to ip in nginx and its running properly. The same thing i need to do for apache2. But how will i give Port number while mapping the ip to Domain. In the cName record, i'm not able to specify the port. Is there any alternative way to resolve this issues.

Question Credit: Sakthi Panneerselvam
Question Reference
Asked May 16, 2019
Posted Under: Network
1 Answers

DNS CNAME record resolves only to IP address, so you cannot specify port, you have to explicitly add port to your URL in a request like this:

Another approach is to use load balancer like for example Haproxy, Traefic, or even Nginx with its reverse proxy capabilities (check this: Then you will be able to use only one port (well, you can use multiple ports as well, but typically port 80 and 443) on its frontend traffic and "routing" it to your backends by some criteria (domain name, path, HTTP header info, cookies, source or destination IP address, etc.).

credit: patok
Answered May 16, 2019
Your Answer