469,286 Members | 2,521 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

IPA behind proxy

Is there a way to retrieve IP address behind a proxy?

Mhaxx

Jul 16 '05 #1
13 7436
Mhaxx <mh***@despammed.com> writes:
Is there a way to retrieve IP address behind a proxy?


Sometimes.

$_SERVER['X_FORWARDED_FOR'] works on some of them, not on others.

--
Chris
Jul 16 '05 #2
On Fri, 05 Sep 2003 10:10:25 +0200, Mhaxx <mh***@despammed.com> wrote:
Is there a way to retrieve IP address behind a proxy?


this is what I use (doesn't always work:

if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']." (through proxy
".$_SERVER['REMOTE_ADDR'].")";
}
else {
$ipaddress = $_SERVER['REMOTE_ADDR'];
}
?>

Jul 16 '05 #3
>this is what I use (doesn't always work:

There isn't $_SERVER['HTTP_X_FORWARDED_FOR'] in my proxy headers! :-((

Are there other ways?

Mhaxx

Jul 16 '05 #4

Are there other ways?


Try this, which I picked up from someone else:
# Function to obtain the IP address behind cache
function getRealIp () {

# Obtain the server addresses
#!# These potentially require an isSet
$HCIP = $_SERVER['HTTP_CLIENT_IP'];
$HXF = $_SERVER['HTTP_X_FORWARDED'];
$HXFF = $_SERVER['HTTP_X_FORWARDED_FOR'];
$RMAD = $_SERVER['REMOTE_ADDR'];

# Logic to ascertain which to use
$ipAddress = ($HCIP != '') ? $HCIP :
($HXF != '') ? $HXF :
($HXFF != '') ? $HXFF :
($RMAD != '') ? $RMAD : '';

# Return the result
return $ipAddress;
}

Martin

Jul 16 '05 #5
>Try this, which I picked up from someone else:

Nothing, I always get the IP address of my proxy!

I think that if my proxy doesn't add IPA visitors header into its
headers, I can't obtain IPA visitors.. is it right?

Mhaxx

Jul 16 '05 #6
Mhaxx <mh***@despammed.com> writes:
Try this, which I picked up from someone else:


I think that if my proxy doesn't add IPA visitors header into its
headers, I can't obtain IPA visitors.. is it right?


Make a PHP page solely containing <?php phpinfo(); ?> View it through
the proxy. Do a search on the page for your real IP. If you can't
find it, the proxy doesn't send it, and no, you can't obtain it. If
you can find it, you should have a big hint as to what the variable
it's in is called.

--
Chris
Jul 16 '05 #7
>the proxy. Do a search on the page for your real IP. If you can't
find it, the proxy doesn't send it, and no, you can't obtain it.


I can't see the "real" IPA in phpinfo().

I have no other ways, right? :-(

Mhaxx

Jul 16 '05 #8
Mhaxx <mh***@despammed.com> writes:
the proxy. Do a search on the page for your real IP. If you can't
find it, the proxy doesn't send it, and no, you can't obtain it.


I can't see the "real" IPA in phpinfo().

I have no other ways, right? :-(


Well, you could ask the user to type their IP into a box on the page.
It might be possible to use Javascript to grab it client-side and put
it into a hidden field, but that's going to be unreliable at best, and
might _really_ annoy some people (if someone's going out of their way
to keep their IP hidden, trying to find it is going to make them
leave, fast).

Looks like you'll just have to give up on this one.

What do you need the IP for, anyway?

--
Chris
Jul 16 '05 #9
>Well, you could ask the user to type their IP into a box on the page.

No no..
What do you need the IP for, anyway?


To trace accesses to my web site, and (maybe) to trace visitors IPA
when they buy something in my merchant site.. I know what you think:
it's not a good idea, because you can change your IPA if you want, so
it's not a secure way..

Mhaxx

Jul 16 '05 #10


What do you need the IP for, anyway?


To trace accesses to my web site, and (maybe) to trace visitors IPA when
they buy something in my merchant site.. I know what you think: it's not
a good idea, because you can change your IPA if you want, so it's not a
secure way..


This will fail. Use sessions instead, which are intended exactly for this
sort of application, and which fairly are simple to set up.

www.php.net/session


Martin

Jul 16 '05 #11
>This will fail. Use sessions instead, which are intended exactly for this
sort of application, and which fairly are simple to set up.

www.php.net/session


I *use* PHP session!
But I need to retrieve IPA..

Mhaxx

Jul 16 '05 #12

I *use* PHP session!
But I need to retrieve IPA..
Did you try the function I posted at Fri, 5 Sep 2003 14:01:59 +0100,
reproduced below. I contend that you won't get any further than that in
getting a visitor's IP address.

If that doesn't work, then I'm still not clear what you're wanting to
achieve exactly.

I had thought you wanted some derivative of the client's IP address,
though perhaps IPA is referring to something I'm not familiar with, as
it's not an acronymn I've come across.

To trace accesses to my web site


http://www.analog.cx/docs/webworks.html is a good guide to what is and
isn't possible, incidentally.
Martin


# Function to obtain the IP address behind cache
function getRealIp () {

# Obtain the server addresses
#!# These potentially require an isSet
$HCIP = $_SERVER['HTTP_CLIENT_IP'];
$HXF = $_SERVER['HTTP_X_FORWARDED'];
$HXFF = $_SERVER['HTTP_X_FORWARDED_FOR'];
$RMAD = $_SERVER['REMOTE_ADDR'];

# Logic to ascertain which to use
$ipAddress = ($HCIP != '') ? $HCIP :
($HXF != '') ? $HXF :
($HXFF != '') ? $HXFF :
($RMAD != '') ? $RMAD : '';

# Return the result
return $ipAddress;
}

Jul 16 '05 #13
>Did you try the function I posted at Fri, 5 Sep 2003 14:01:59 +0100,

Yes, but with no success.
If that doesn't work, then I'm still not clear what you're wanting to
achieve exactly.
I only want to get client's IP address!
...but I can't because my web server is behind a proxy, so if I try to
retrieve client's IP address I get proxy's IP address!
I had thought you wanted some derivative of the client's IP address,
No, exactly the IP address.
though perhaps IPA is referring to something I'm not familiar with, as
it's not an acronymn I've come across.
IPA = IP address ;-)
http://www.analog.cx/docs/webworks.html is a good guide to what is and


I'm connecting to it to see..

Thanx, bye.

Mhaxx

Jul 16 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Bill Hauver | last post: by
2 posts views Thread by Yassar | last post: by
5 posts views Thread by james.dixon | last post: by
2 posts views Thread by demotis | last post: by
reply views Thread by aladdinm1 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.