This is a discussion on Log User's real IP and not there Proxy Server's??? within the Apache Web Server forums, part of the Web Server and Related Forums category; I've tried the apache docs and google but since I don't really know what I'm looking for ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I've tried the apache docs and google but since I don't really know what
I'm looking for I thought I'd ask here. First off I'm running: Mac OSX 10.2.8 Apache 1.3.27 Apache is logging the IP address of the user's proxy server in access_log. I'm wondering if there is a way to get it to log the user's real IP address instead. I realize that this isn't actually a log issue and that it lies deeper within apache and I'm assuming that making this change will also change the IP address the PHP recognizes for the user. This is most likely a simple matter but I truely have no idea where to start looking. If I'm barking up the wrong tree let me know. Thanks payback |
|
|||
|
payback wrote:
> I've tried the apache docs and google but since I don't really know what > I'm looking for I thought I'd ask here. > > First off I'm running: > Mac OSX 10.2.8 > Apache 1.3.27 > > Apache is logging the IP address of the user's proxy server in access_log. > I'm wondering if there is a way to get it to log the user's real IP address > instead. I realize that this isn't actually a log issue and that it lies > deeper within apache and I'm assuming that making this change will also > change the IP address the PHP recognizes for the user. although I don't think it's "resolvable", have you looked into: http://httpd.apache.org/docs/mod/mod...g.html#formats the proxy would need to forward the IP, but AFAIK proxies don't do that... -- Robi |
|
|||
|
payback wrote:
> I've tried the apache docs and google but since I don't really know what > I'm looking for I thought I'd ask here. > > First off I'm running: > Mac OSX 10.2.8 > Apache 1.3.27 > > Apache is logging the IP address of the user's proxy server in access_log. > I'm wondering if there is a way to get it to log the user's real IP address > instead. I realize that this isn't actually a log issue and that it lies > deeper within apache and I'm assuming that making this change will also > change the IP address the PHP recognizes for the user. > > This is most likely a simple matter but I truely have no idea where to > start looking. If I'm barking up the wrong tree let me know. In PHP, this is accessible via the $_SERVER['X_FORWARDED_FOR'] variable when it is set. I believe that it's the apache variable ENV{'HTTP_X_FORWARDED_FOR'} Therefore, going by the log format (http://httpd.apache.org/docs/mod/mod...g.html#formats), I believe you could simply add the %{HTTP_X_FORWARDED_FOR}e to your LogFormat line to get this recorded. HTH -- Justin Koivisto - spam@koivi.com PHP POSTERS: Please use comp.lang.php for PHP related questions, alt.php* groups are not recommended. |
|
|||
|
Robi a écrit:
> payback wrote: >> I've tried the apache docs and google but since I don't really know what >> I'm looking for I thought I'd ask here. >> >> First off I'm running: >> Mac OSX 10.2.8 >> Apache 1.3.27 >> >> Apache is logging the IP address of the user's proxy server in >> access_log. I'm wondering if there is a way to get it to log the user's >> real IP address instead. I realize that this isn't actually a log issue >> and that it lies deeper within apache and I'm assuming that making this >> change will also change the IP address the PHP recognizes for the user. > > although I don't think it's "resolvable", have you looked into: > http://httpd.apache.org/docs/mod/mod...g.html#formats > > > the proxy would need to forward the IP, but AFAIK proxies don't do that... > > Agreed Also the proxied address often might be a local one, unusefull. -- Marc Nadeau La Pagerie http://www.pagerie.com |
|
|||
|
*** Justin Koivisto wrote/escribió (Thu, 13 Nov 2003 21:00:25 GMT):
> In PHP, this is accessible via the $_SERVER['X_FORWARDED_FOR'] variable > when it is set. Actually, X_FORWARDED_FOR can be a comma-separated list. You need some extra work to make sure you get the right IP: function real_ip(){ if($tmp=$_SERVER['HTTP_X_FORWARDED_FOR']){ $tmpip=explode(",", $tmp); return trim($tmpip[0]); }else return $_SERVER['REMOTE_ADDR']; } To make it worse, not all proxies use this variable. Some use Client-IP and God knows what else. I've been playing around with httpd.conf in order to create a new variable with real IP but haven't been successful yet. I can log my new variable but I still don't know how to fill it in (I'd need to call an external program and I don't know whether that's possible). SetEnv real_ip 9.8.7.6 PassEnv real_ip LogFormat "[%{real_ip}i] %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" test -- -- -- Álvaro G. Vicario - Burgos, Spain -- |
|
|||
|
Alvaro G Vicario <alvaro_QUITAR_REMOVE@telecomputeronline.com> wrote in
news:jo18c3d12b3m$.cjzjzjewdfsl$.dlg@40tude.net: > *** Justin Koivisto wrote/escribió (Thu, 13 Nov 2003 21:00:25 GMT): >> In PHP, this is accessible via the $_SERVER['X_FORWARDED_FOR'] >> variable when it is set. > > Actually, X_FORWARDED_FOR can be a comma-separated list. You need some > extra work to make sure you get the right IP: > > function real_ip(){ if($tmp=$_SERVER['HTTP_X_FORWARDED_FOR']){ > $tmpip=explode(",", $tmp); return trim($tmpip[0]); }else return > $_SERVER['REMOTE_ADDR']; } > > To make it worse, not all proxies use this variable. Some use > Client-IP and God knows what else. > > I've been playing around with httpd.conf in order to create a new > variable with real IP but haven't been successful yet. I can log my > new variable but I still don't know how to fill it in (I'd need to > call an external program and I don't know whether that's possible). > > SetEnv real_ip 9.8.7.6 > PassEnv real_ip > > LogFormat "[%{real_ip}i] %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" > \"%{User-Agent}i\"" test > > > Thanks for all of your help... This is starting to look far too complicated. Perhaps I won't bother then. But thanks anyways, it is appreciated. payback |