These PHP server variables provide the IP address information in different ways based on the condition how the website is accessed. So basically these variables used to track the user’s location.
You can get these information with the help of below three server variables.



When any user visit your site without any proxy server in that case you can get the IP address using [code]REMOTE_ADDR[/code] server variable. So in that case [code]HTTP_X_FORWARDED_FOR[/code] and [code]HTTP_VIA[/code] will not be available.

Note: [code]HTTP_VIA[/code] and [code]HTTP_X_FORWARDED_FOR[/code] will be only populated if web server detects the use of the Proxy Server.

Now for understanding the [code]HTTP_VIA[/code] and [code]HTTP_X_FORWARDED_FOR[/code] check the below scenario:

Suppose any user from India visits my site from the proxy server of the USA. Below I have listed the user’s flow with dummy IP addresses.


User( India ) >> Proxy (USA >> https://xpertdeveloper.com

AS per above scenario [code]REMOTE_ADDRESS[/code] will populated with, [code]HTTP_VIA[/code] will populated with and [code]HTTP_X_FORWARDED_FOR[/code] will populated with

So if any user visits your site with the proxy server then [code]REMOTE_ADDRESS[/code] is the IP address of the machine which is actually making the request to your website, [code]HTTP_VIA[/code] is the IP address of the proxy server and [code]HTTP_X_FORWARDED_FOR[/code] is the IP address of the actual user who uses the proxy server.


Note: If request is made through proxy server the [code]REMOTE_ADDR[/code] will be same as [code]HTTP_VIA[/code].

  • Andrei
    August 22, 2011 at 11:38 am

    Very interesting your post!

  • megainfo
    August 24, 2011 at 2:55 pm

    NIce!! thanks

  • Reazul
    September 8, 2011 at 9:37 pm

    Nice and very helpful post. It solved my confusion. Thanks.

  • tvarkarastis
    December 5, 2011 at 10:06 pm

    thanx good article, playing with proxies at the moment and your article helped me

  • Android VPN
    March 19, 2012 at 5:18 pm

    Just additional information the HTTP_VIA variable do not just display the proxy server’s IP address. It normally shows what proxy software is being used, including it’s version number.

    Example: eg: HTTP_VIA: HTTP/1.1 255-255-255-255.HINET-IP.hinet.net (Squid/1.3.28)</code?

    In this sample the proxy domain and port are displayed, it also display the proxy software and version used.

  • Justin jacob
    Justin jacob
    April 26, 2013 at 11:44 am

    i had a website to check the IP address and proxy ,and the site is in https ,in https http_via is not working and in http its working ,how to show http_via in https environment


Leave a Reply

Your email address will not be published. Required fields are marked *