0

Is it in anyway possible to rewrite (or via some DNS trick) http://localhost:1337/ to http://myswebsite/.

I did find the way to add a custom DNS entry at the system32 hosts file, but this does not work with a port.

The reason I want to have this, is because I'd like to be able to have a dynamic port, which may change day to day. Yet I want to access the http server running on that port anytime without changing the port for the request. So it would be easier to request http://mywebsite/ instead of http://localhost:%this_port_can_be_whatever%/

Is there maybe another way to make this possible?

MVr
  • 118
  • 1
  • 8
  • What you want to do can not be done with DNS. You'll need to set up some kind of proxy to forward the requests received on port 80 to the dynamic web-site. But you will still need to have port 80 open to the server, so why not just place the web-site on port 80, to avoid the troubles of setting up a proxy? – Lars Lind Nilsson Jul 25 '16 at 08:54
  • The idea is, that the server will be running somewhere in the back, not interfering with any other program running, so also no web servers on port 80. – MVr Jul 25 '16 at 15:27
  • You'll need something to be listing on port 80 somewhere in the setup, else you won't be able to access the site without a port specified in the URL. When you don't specify a port in a URL, the browser will connect to port 80. `http://mywebsite/` is the same as `http://mywebsite:80/`. – Lars Lind Nilsson Jul 25 '16 at 17:07
  • I'm aware of the port 80 being some default value to the http server. But if port 80 is set somewhere on your pc or in your browser, wouldn't that make it possible for me to add and / or edit a 'default port' for a given url? – MVr Jul 25 '16 at 17:30
  • Anything in front of the first / (not counting the 2 in http://) is used by the browser to decide which server and port to connect to. The domain is converted to an ip-address and then a TCP connection is made to that ip-address on port 80 (or another port if specified in the URL). Then the browser send a GET request for the path part of the URL (and also sends a header specifying the servername in case more than one site is hosted on the server). So no information after the first / is used when creating the initial TCP connection. – Lars Lind Nilsson Jul 25 '16 at 17:37

0 Answers0