I have an Azure Ubuntu VM server with multiple websites. Say website A = 81, website B = 82. These endpoints are exposed and I can access the website externally using <ip address>:<port>.

I would like each of my websites to have a friendly domain name but in the CNAME records, I cannot specify a port - I can only specify an IP address.

Normally, this is fine because it'll just default to port 80. But I have multiple websites and therefore they cannot all be port 80 - so how can I have a domain forwarded to a Azure VM pointing to a non 80 port?

  • You cannot do this using DNS records. The only way would be to setup some sort of reverse proxy in front of the servers. – Jenny D says Reinstate Monica May 28 '15 at 12:33
  • @JennyD : Ah ok, so how would I do that using Azure VMs? – RoboShop May 28 '15 at 12:33
  • @JennyD : sorry is this something I would do inside the VM as in have one end point pointing to 80 and then a reverse proxy installed to point to my various sites? Or some Azure configuration outside the VM? – RoboShop May 28 '15 at 12:35
  • You can do it within the VM, or with a separate server. Or you could use VirtualHosts to run all the sites on the same port. – Jenny D says Reinstate Monica May 28 '15 at 12:37
  • 2
    Why don't you just use Apache name based virtual hosting? you can easily route any URL to any application directory based on the %HOST the request comes in on. so abc.com > /var/www/www.abc.com/html/index.php and xyz.com > /var/www/www.xyz.com/html/index.php – Jacob Margason May 28 '15 at 12:37

You can't do that at the DNS level, because DNS only maps names to IP addresses and has no knowledge at all of TCP ports.

There are various solutions (a reverse proxy, multiple IP addresses...), but the simplest one would be to configure all websites to listen on port 80 and then distinguish them using host headers; since you are using HTTP instead of HTTPS, this should pose no problem at all.

You are on Ubuntu, so you're probably using Apache; Virtual Hosts are the way to go.

  • 1
    Not using Apache - I've got a couple of NodeJS (Meteor) apps running on this server. But I'm sure there's some sort of NodeJS version of virtual hosts – RoboShop May 28 '15 at 12:42
  • You'll be better off using nginx in front of your NodeJS applications. (@RoboShop) – gnur May 28 '15 at 12:52
  • @gnur : yes that's what I'm reading up on now – RoboShop May 28 '15 at 13:05

Your Answer

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

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