Log User's real IP and not there Proxy Server's???

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 ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-13-2003
payback
 
Posts: n/a
Default Log User's real IP and not there Proxy Server's???

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
  #2 (permalink)  
Old 11-13-2003
Robi
 
Posts: n/a
Default Re: Log User's real IP and not there Proxy Server's???

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
  #3 (permalink)  
Old 11-13-2003
Justin Koivisto
 
Posts: n/a
Default Re: Log User's real IP and not there Proxy Server's???

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.

  #4 (permalink)  
Old 11-14-2003
Marc Nadeau
 
Posts: n/a
Default Re: Log User's real IP and not there Proxy Server's???

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

  #5 (permalink)  
Old 11-14-2003
Alvaro G Vicario
 
Posts: n/a
Default Re: Log User's real IP and not there Proxy Server's???

*** 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 --
  #6 (permalink)  
Old 11-14-2003
payback
 
Posts: n/a
Default Re: Log User's real IP and not there Proxy Server's???

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:13 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0