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

I'm trying to setup my host file at home in order to have access to my webserver from my outside IP.

If I go http://localhost/test I have access to my apache but If I try http://myip/test I see a 404 from my router.

The nat rule / fw is working since friends from outside can reach my server.

I tried to add the ip in my host file but that doesnt seem to work.

127.0.0.1 localhost 90.x.x.x

any clue ?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

You can't do that.

The hosts file is only for mapping between names and ip addresses. You cannot use it to map one ip address to another ip address. So you could do this:

127.0.0.1 www.my.computer

...and then enter http://www.my.computer/ in your web browser.

You could, in theory, give your local device the same ip address as your router's outside address, which would allow you do what you've described but really isn't a configuration I would recommend.

share|improve this answer
    
I'm testing a OAuthClient so google is redirecting me to my localip that's why i'm trying to do this. Maybe a local dns server ? –  Paté Jun 23 '11 at 20:26
    
so the incoming request is pointed at your router's address? If so, you need to forward ports to your local address –  sreimer Jun 23 '11 at 20:28
    
Or set up an alias address on your local system. But honestly, if Google is redirecting you to an ip address rather than a hostname, something else is broken -- I would suggest using the hostname that corresponds to your home ip address, and then put that in your local hosts file. –  larsks Jun 23 '11 at 20:30
    
Yup, I set up a dyndns and added this to my hosts file and changed my google key for that domain and it works fine now...thx –  Paté Jun 23 '11 at 20:38

Your problem is not with your hosts file (though HAVING a hosts file is a problem -- There is almost always no good reason to do this!). Your problem is with your firewall, specifically something called "NAT Reflection". (Google your router/firewall and that term to see if it's possible to set up NAT reflection in your case).

A better alternative would probably be to access your internal server by a DNS hostname, and override that locally (either via a hosts file (YUCK!) or internal DNS) to point at the private IP address.

share|improve this answer

Are you using the Apache webserver? If so, this might be a matter of fixing a directive in your httpd.conf file. I'd think that the ServerName using your IP number might be the fix.

 Servername <externipnumber>:80

 Listen <externipnumber>: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.