How can I assign domain name to port number?

7,148

Domain names have nothing to do with port numbers at all. All a domain name does is resolve to an IP address, the port is completely independent of that process. In order to achieve what you are wanting to do you will either need to change the server listening port to port 80 (which is the default HTTP port), port 443 (which is the default HTTPS port), or if changing listening port numbers is not an option you will need to implement some form of redirecting logic which can be a proxy server. As you don't mention the network topology I will add here that some business line routers (especially those that support port forwarding) also support changing the port. Either way it is not as simple as a DNS configuration with your domain name and will in fact need to be done at the network level, either in server configuration, gateway configuration, or with an intermediary system like a proxy server.

Share:
7,148

Related videos on Youtube

Frostless
Author by

Frostless

Updated on September 18, 2022

Comments

  • Frostless
    Frostless over 1 year

    I have built a socket io project and the server.js listens to a specific port number 2000.

    Now I have uploaded this project to the server and I can access the server by entering ipAddress:2000 with ease. I have also purchased a domain and have it attached to the ip address. So now I can visit the server by domainName:8000.

    But that is not what I want eventually, I want to visit my server by just entering the ip address or just the domain name.

    How can I achieve this?

    • closetnoc
      closetnoc about 7 years
      How can I assign domain name to port number? Simple answer? You can't. You would have to use a proxy to answer port 80 and rewrite the request packets to 8000 or possibly install a web server and redirect port 80 to port 8000. Proxy servers are the transparent option. Users see none of the magic behind the scenes. With a redirect, they will. Cheers!!
    • Steve
      Steve about 7 years
      @closetnoc why a comment rather than an answer?
    • closetnoc
      closetnoc about 7 years
      @Steve I m trying to leave room for new users to answer. Users on this site gave me a lot of opportunity and I am just trying to pass that same grace along. Sometimes I jump in. I should more often. Just not terribly focused these days. I have too many irons in the fire right now.
  • closetnoc
    closetnoc about 7 years
    Nice mentioning port forwarding! I forgot about that option. This is not available in a hosting environment but could be available otherwise. Proxies, are deep packet inspection devices that rewrite the request packet according to rules while maintaining state so that reversing response packets is possible. Essentially, a proxy and a firewall are the same breed of beasts tasked to do two different things. This is why some firewalls will offer proxy services. A rewrite as in using .htaccess, as you know is not that sophisticated. Also nice mention for simply changing the port the app runs on.
  • Frostless
    Frostless about 7 years
    Thanks for all the answer. I first tried to changed the port to 80 but I got an error. I eventually used the reverse proxy to solve this issue.