Welcome to Geeklog, Anonymous Thursday, April 25 2024 @ 12:50 pm EDT

Geeklog Forums

fixed addressing problem internal vs external network


Ron Christian

Anonymous
happy
Background: The server and my client machines are on an unroutable internal network (10.0.0.XX). The DSL router maps my static external IP to the server on the 10.0.0 network (for ports 80 and 22 only). The external URL redirect service redirects three domain names to my_external_ip/~domain, which eventually gets to the right bits on my server.

The problem: Because the URL redirect is to my_external_ip/~domain, the site_url needs to be set to http://my_external_ip/~domain. But the internal machines can't access my_external_ip. If I set site_url to http://10.0.0.XX/~domain, I can access the websites from the internal machines. but not from the outside. And because of pecularities with the domain service, virtual hosts doesn't work.

I've worked around this with scripts called "inside" and "outside" which make the proper changes. When I work on the websites, I run "inside", and when I'm done, I run "outside" to set the site_url back to what it should be.

This sucks, frankly, and it's more complicated than my daughter (who manages her own geeklog) wants to deal with.

So today I finally hunted down the bit of code and made some changes.

If you open public_html/lib-common.php and scroll down to where config.php is included, replace the require_once string with the following:

// Get the ip address of the client
$ip = getenv('REMOTE_ADDR');
// If the client's ip address is on the local network, use
// the internal config.php.
if (strncmp("10.0.0",$ip,6) == 0)
{
require_once( '/var/www/html/my_geeklog/config.inside.php' );
}
else
{
require_once( '/var/www/html/my_geeklog/config.php' );
}

This allowed me to run a different config.php depending on whether the remote machine was on my local net or out on the internet. Whether the external machine is being NATted doesn't matter, because REMOTE_ADDR in this case returns the address of the router, not the unroutable address of the machine.

Anyway, it works, I'm happy, and now wife and daughter can access the local blogs without having to dink with them first.

Hope this helps someone.


Ron
 Quote

All times are EDT. The time is now 12:50 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content