Reputation: 516
Let's say that I need to setup a virtual host with the server name text.dev, is there a way so I can enter test.dev in my browser without a port number? My xampp is running on port 8080. I have to run on this port.
Currently, I can get test.dev:8080 to go the correct directory, but is there a way I can set test.dev to automatically go to port 8080. Any help would be appreciated, Thanks.
Upvotes: 0
Views: 1986
Reputation: 3738
The only way you can do this is NAT forwarding port 80 to 8080. This is really easy with iptables, but this is only for Linux. I am not sure which OS you use. If you are using Windows, I don't think you have some equivalent.
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 8080
Upvotes: 0
Reputation: 42875
This is not possible directly they way you sketch it. This has nothing to do with the virtual host configuration, but with the browser behavior. If you do not specify a port, then the browser will always connect to port 80. nothing you can do against that.
So your only bet is to listen on port 80. If you cannot or do not want to do that with your http server, then you have to forward requests from that port to the one your virtual host listens on. There are several options for such port forwarding: firewall based, by using a simple socket listener which acts like a proxy or by means of a tunnel, for example setup using the ssh tools.
Upvotes: 2