Forum Moderators: phranque

Message Too Old, No Replies

how to surf localhost when offline?

Force local redirection when apache on local computer that goes offline.

         

tombammann

2:10 pm on Jan 16, 2006 (gmt 0)

10+ Year Member



Hello Apache gurus and novices alike.

I've spent hours and hours searching for a solution to my problem, but to no avail. I've read lots of documentation, and I'm starting to get a headache :)

I have my domain hosted on my local computer, which is behind a router. (i.e. http://my_account.example_dyn_dns.org )

From my computer, I can surf my website like anyone else can (i.e. http://my_account.example_dyn_dns.org ). I can also surf it via http://localhost, although everything is linked via my blogging software to http://my_account.example_dyn_dns.org

When I disconnect my router, I can no longer surf http://my_account.example_dyn_dns.org even if loading http://localhost, because the blogging software has all its links to http://my_account.example_dyn_dns.org.

The server does load all the web pages locally, I know this because even after clearing the cache I have large picture files large lightning quick.

However, my problem is that I'd like to set up apache so that I can browse (and edit) my site offline. This would mean of course I can't load it via http://my_account.example_dyn_dns.org because the router won't find it, but I'm thinking I should be able to load http://localhost, let apache "detect" that it's 127.0.0.1 accessing the server, and then "translate on the fly" anything from http://my_account.example_dyn_dns.org into http://localhost .

I would then be able to work offline (for example when my ISP goes down, or if in the future I host my blog from a laptop which occasionally gets taken away from home, or even to just save router/ISP traffic!)

The most relevant post I've been able to find is from a couple years ago:

[webmasterworld.com...]

but it was never resolved. I've looked into using Simple DNS Plus but I don't understand anything. On their website I understand they say for this problem to use their "HTTP Router" freeware but this doesn't work because I can't host both things on port 80.

I'm confident this is possible, could anyone please help? I'm not able to return any favours on this forum, but I swear I'm due for some good karma :)

[edited by: jdMorgan at 5:19 pm (utc) on Jan. 16, 2006]
[edit reason] Examplified and de-linked [/edit]

jdMorgan

5:41 pm on Jan 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The usual method for 'surfing' your own locally-hosted site from behind your firewall is to modify the 'hosts' file to include the locally-hosted domains.

This extensionless file is present on Windows and *nix machines, but its location varies, so just search for it. Entries in this file are essentially a 'local DNS lookup.' Each machine on your LAN will need these entries, and the ones that don't host the site will need to be updated frequently if you use DHCP on your network.

There's usually a file called hosts.sam in the same directory that provides a sample configuration for you to look at.

Jim

tombammann

2:42 am on Jan 18, 2006 (gmt 0)

10+ Year Member



Thanks very much, this worked a treat. I also added 127.0.0.1 to make it the primary DNS lookup on my computer, so it doesn't timeout from trying to look through my router, before it loads the pages.

All I need to do now is work out why other computers on the LAN can't access it, but I think that's just a matter of making their primary DNS lookup the ip address of the webserver, and adding the webserver's ip address to the hosts file.

Thanks again, and case closed!