By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,831 Members | 2,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,831 IT Pros & Developers. It's quick & easy.

IPA behind proxy

P: n/a
Is there a way to retrieve IP address behind a proxy?

Mhaxx

Jul 16 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
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

P: n/a
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

P: n/a
>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

P: n/a

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

P: n/a
>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

P: n/a
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

P: n/a
>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

P: n/a
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

P: n/a
>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

P: n/a


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

P: n/a
>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

P: n/a

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

P: n/a
>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.