[PHP] alias address in REMOTE_ADDR

2012-05-12 Thread Tóth Csaba
Hi Everyone,

I've run into a curious problem, not even really sure it's PHP, but that's 
where 
I caught it, so here it is:

I have two servers hanging on the net, without proxies. Let's call them Server1
and Server2. Server1 has multiple IP addresses, configured as aliases. My 
problem:
When I do a wget --spider from 1 to 2, I get the eth0 (not alias) address in 
Apache's accesslog on Server2. But when I do a 
file_get_contents(http://server2.tld),
and observe the $_SERVER['REMOTE_ADDR'] on Server2, I get one of the alias IP 
addresses 
back. What can cause this? I really need the eth0 IP address back in 
REMOTE_ADDR.

Regards,
Csaba

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] alias address in REMOTE_ADDR

2012-05-12 Thread shiplu
On Saturday, May 12, 2012, Tóth Csaba wrote:

 Hi Everyone,

 I've run into a curious problem, not even really sure it's PHP, but that's
 where
 I caught it, so here it is:

 I have two servers hanging on the net, without proxies. Let's call them
 Server1
 and Server2. Server1 has multiple IP addresses, configured as aliases. My
 problem:
 When I do a wget --spider from 1 to 2, I get the eth0 (not alias) address
 in
 Apache's accesslog on Server2. But when I do a file_get_contents(
 http://server2.tld),
 and observe the $_SERVER['REMOTE_ADDR'] on Server2, I get one of the alias
 IP addresses
 back. What can cause this? I really need the eth0 IP address back in
 REMOTE_ADDR.



On server2 make sure the metric of both interface in the routing table is
not same. Same metric can cause this behavior. Change the metric of eth0 to
a lower value than the other. Then try again.


 Regards,
 Csaba

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader


Re: [PHP] alias address in REMOTE_ADDR

2012-05-12 Thread shiplu
On Saturday, May 12, 2012, shiplu wrote:



 On Saturday, May 12, 2012, Tóth Csaba wrote:

 Hi Everyone,

 I've run into a curious problem, not even really sure it's PHP, but
 that's where
 I caught it, so here it is:

 I have two servers hanging on the net, without proxies. Let's call them
 Server1
 and Server2. Server1 has multiple IP addresses, configured as aliases. My
 problem:
 When I do a wget --spider from 1 to 2, I get the eth0 (not alias) address
 in
 Apache's accesslog on Server2. But when I do a file_get_contents(
 http://server2.tld),
 and observe the $_SERVER['REMOTE_ADDR'] on Server2, I get one of the
 alias IP addresses
 back. What can cause this? I really need the eth0 IP address back in
 REMOTE_ADDR.



 On server2 make sure the metric of both interface in the routing table is
 not same. Same metric can cause this behavior. Change the metric of eth0 to
 a lower value than the other. Then try again.


Correction. On server2 should be On server1.


-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader


Re: [PHP] alias address in REMOTE_ADDR

2012-05-12 Thread Jim Lucas

On 5/11/2012 10:57 PM, Tóth Csaba  wrote:

Hi Everyone,

I've run into a curious problem, not even really sure it's PHP, but that's where
I caught it, so here it is:

I have two servers hanging on the net, without proxies. Let's call them Server1
and Server2. Server1 has multiple IP addresses, configured as aliases. My 
problem:
When I do a wget --spider from 1 to 2, I get the eth0 (not alias) address in
Apache's accesslog on Server2. But when I do a 
file_get_contents(http://server2.tld),
and observe the $_SERVER['REMOTE_ADDR'] on Server2, I get one of the alias IP 
addresses
back. What can cause this? I really need the eth0 IP address back in 
REMOTE_ADDR.

Regards,
Csaba



What IP address is your Apache bound to?  You eth0 or one of the alias IPs?

Jim

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] SOLVED: [PHP] alias address in REMOTE_ADDR

2012-05-12 Thread Tóth Csaba
Hi,

shiplu and Jim, many thanks for the hints, I solved it; wasn't related to PHP, 
but I will write it down so if others search for this problem, at least they 
will have one solution that worked. 

Jim: the Apache was configured to listen on all interfaces - I had to, because 
I have multiple SSL-enabled hosts with different keys

shiplu: it was the metric! Only problem, because these are alias interfaces, a 
simple ifmetric doesn't cut it:
#~ ifmetric eth0:1 20
SIOCSIFMETRIC: operation not supported
So I had to disable the alias interfaces with ifconfig down, the re-enable 
them; after that, add the gateways like this:
#~ route add default gw GATEWAYIP metric 10
so now my routing table has a metric 0 gateway for eth0, and a metric 10 for 
both aliases.

Many thanks again, and have a nice weekend!

Regards,
Csaba


On Fri, 11 May 2012 23:54:56 -0700, Jim Lucas wrote:
 On 5/11/2012 10:57 PM, Tóth Csaba  wrote:
 Hi Everyone,

 I've run into a curious problem, not even really sure it's PHP, but that's 
 where
 I caught it, so here it is:
 ...
 Regards,
 Csaba

 
 What IP address is your Apache bound to?  You eth0 or one of the alias IPs?
 
 Jim


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] alias address in REMOTE_ADDR

2012-05-12 Thread Mike Mackintosh


On May 12, 2012, at 2:54, Jim Lucas li...@cmsws.com wrote:

 On 5/11/2012 10:57 PM, Tóth Csaba  wrote:
 Hi Everyone,
 
 I've run into a curious problem, not even really sure it's PHP, but that's 
 where
 I caught it, so here it is:
 
 I have two servers hanging on the net, without proxies. Let's call them 
 Server1
 and Server2. Server1 has multiple IP addresses, configured as aliases. My 
 problem:
 When I do a wget --spider from 1 to 2, I get the eth0 (not alias) address in
 Apache's accesslog on Server2. But when I do a 
 file_get_contents(http://server2.tld),
 and observe the $_SERVER['REMOTE_ADDR'] on Server2, I get one of the alias 
 IP addresses
 back. What can cause this? I really need the eth0 IP address back in 
 REMOTE_ADDR.
 
 Regards,
 Csaba
 
 
 What IP address is your Apache bound to?  You eth0 or one of the alias IPs?
 
 Jim
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

Do a netstat -ab and see what ip/ports apache is listening on. 

Mike Mackintosh
ZCE PHP5.3
www.highonphp.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php