Page 1 of 1

How to retrieve web server ip

Posted: Wed Jul 09, 2003 1:04 pm
by hedge
I was using $_SERVER['LOCAL_ADDR'] to determine the IP of the webserver. This works fine if run from an 'external browser' but when the browser is run from the web server it gives me 127.0.0.1...

I have used phinfo to look at all the server vars, they are all set to 127.0.0.1, I was hoping maybe there was a constant set by php or some other method.

this is win2k/IIS/php4.3.1



Does anyone have an idea how I can get the actual IP when I run from the server.

Thanks.

Posted: Wed Jul 09, 2003 1:23 pm
by McGruff
Any website has to have a constant IP: once you know what it is just create a user-defined constant in a config.php file or somewhere?

Posted: Wed Jul 09, 2003 2:23 pm
by hedge
McGruff wrote:Any website has to have a constant IP: once you know what it is just create a user-defined constant in a config.php file or somewhere?
yeah, it looks like that's what I will have to do. The issue is that we have multiple web servers behind a load-balancer. Up to this point I have been able to have exactly the same code on all servers, now I need to have something special on each server.