Edit report at https://bugs.php.net/bug.php?id=66208&edit=1
ID: 66208
User updated by: tronox at hotmail dot com
Reported by: tronox at hotmail dot com
Summary: PHP-FPM Bind to address
Status: Wont fix
Type: Feature/Change Request
Package: *Network Functions
Operating System: Amazon AMI
PHP Version: 5.5.6
Block user comment: N
Private report: N
New Comment:
More specifically to your exact words:
"talking about the IP address that remote servers see your HTTP requests coming from".
Previous Comments:
------------------------------------------------------------------------
[2013-11-30 09:49:28] tronox at hotmail dot com
http://example.com/whatismyip.php code is:
<?php echo $_SERVER['REMOTE_ADDR'];?>
To explain it a bit better I guess. When I use file_get_contents('http://example.com/whatismyip.php') I get
back the server's eth0 main IP. Rather then the IP, which while using phpinfo(), returned by
_SERVER["SERVER_ADDR"].
Meaning the IP PHP is using to connect outside of the server is being defined by the server's
default IP even though _SERVER["SERVER_ADDR"] is being set differently per host.
Now most of the functions in PHP already support a bindto via stream. However that would mean I
would have to re-write code to bind to specific IPs. Not to mention having to babysit each site to
make sure they were doing that as well.
I see no reason why PHP shouldn't, or at least have an option for it, bind outgoing connections
defaultly to the IP set in _SERVER["SERVER_ADDR"].
------------------------------------------------------------------------
[2013-11-30 09:14:43] requinix@php.net
So wait, are you talking about the IP address that your web server is binding to, which is what your
title and latest reply are talking about (despite how it's not PHP-FPM that does that), or are
you talking about the IP address that remote servers see your HTTP requests coming from, which is
what your description was about?
------------------------------------------------------------------------
[2013-11-30 08:36:35] tronox at hotmail dot com
MANY services out there allow for binding of their outgoing IPs. Even PHP does via scripting. I see
no reason why php can't have a default IP binding setting. This would not only make it possibly
more secure. But it would also support virtual hosting much better.
Making a VPM for every virtual host is a bit much. A Simple chroot suffices for most things packed
with open_basedir. The only remaining issue is what IP clients are using for outgoing connections.
Which opens a whole lot of security issues on a system. IE: I can't block or allow specific IPs
outgoing traffic for specific ports. I can't track traffic usage reliably for a specific IP.
------------------------------------------------------------------------
[2013-11-30 07:39:22] requinix@php.net
A full explanation of why that's not possible is out of the scope of this bug reporting system,
but suffice it to say that's not how networking works.
------------------------------------------------------------------------
[2013-11-30 06:40:23] tronox at hotmail dot com
Description:
------------
While running multiple hosts on multiple ips:
I'm able to get a specific _SERVER["SERVER_ADDR"] for each host. However when using
functions such as file_get_contents('example.com/whatismyip.php') it will always return
the main IP of the server rather then the IP in _SERVER["SERVER_ADDR"].
My request is that either the IP used for functions such as file_get_contents is set to
_SERVER["SERVER_ADDR"] or there be a setting that can be passed into PHP or PHP-FPM so
that the outgoing IP can be set.
Seems that is _SERVER["SERVER_ADDR"] returns a specific IP that that should be used as
default for outgoing traffic.
Expected result:
----------------
_SERVER["SERVER_ADDR"] be used as the default IP/Interface for outgoing PHP traffic.
Actual result:
--------------
_SERVER["SERVER_ADDR"] is ignored and the server's main IP is used instead.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66208&edit=1