Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Using the hosts file, I can't do something like this:

127.0.0.1:8080 testing

Therefore I will have to write

127.0.0.1 testing
http://testing:8080 

in order to do the same thing.

The problem is that I need to be able to access the IP without entering any port. Do I have any options to do such a thing?

share|improve this question
    
I've removed the DNS tags from this, as port bindings have nothing to do with DNS. DNS is simply a mechanism to get an IP from a name and vice versa. –  MDMarra Jun 4 '10 at 12:55

4 Answers 4

You can set up a reverse proxy to serve at port 80, and forward all requests to 8080.

Apache is one of the web servers that can do this for you. There is a basic reverse proxying example in the mod_proxy documentation.

share|improve this answer

The hosts file only binds host names to IP addresses.

By default HTTP runs over port 80. So by binding a host name to 127.0.0.1 and then hitting the host name in your browser (over HTTP) you are implying port 80.

You would need to set up a proxy server that listened to port 80 and forwarded the requests on to port 8080. Your web server would still have to run on port 8080

share|improve this answer

hosts file is to associate a name to an ip.
What you want to do is a firewall duty.
Or you configure the application to run on 80 instead of 8080.
With iptables you could do something like:

iptables -t nat -I PREROUTING -p tcp -i eth0 -d 127.0.0.1 --dport 8080 -j DNAT --to-destination 127.0.0.1:80
share|improve this answer
    
It would be better to have this administered by the proxy than routing though though IPtables otherwise this just adds an extra level of complexity to the system. Most people would automatically start looking at the web server configs for a proxy if they had to debug an issue or learn how everything is setup. –  Paul Jun 4 '10 at 12:58

You need extra privileges to listen on ports below 1000, which is probably why you are listening on port 8080 rather than port 80. You can set up a reverse proxy using Apache, Squid, Varnish or various other proxies.

Or you could just get the software to listen on port 80 by letting it escalate privileges and passing the correct parameters. What's the software? We'll probably be able to help you get it listening on port 80.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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