<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Gotcha: HTTP_X_FORWARDED_FOR returns multiple IP addresses</title><link>http://weblogs.asp.net/james_crowley/archive/2007/06/19/gotcha-http-x-forwarded-for-returns-multiple-ip-addresses.aspx</link><description>I hit a small gotcha this evening. A visitor to Developer Fusion reported that they couldn't gain access to the site at all, because our IP address detection logic was failing. We were checking the "HTTP_X_FORWARDED_FOR" header for an IP address, before</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Bittorrents.RO - Page 111 - TORRENTs.RO</title><link>http://weblogs.asp.net/james_crowley/archive/2007/06/19/gotcha-http-x-forwarded-for-returns-multiple-ip-addresses.aspx#7143972</link><pubDate>Thu, 09 Jul 2009 20:05:14 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7143972</guid><dc:creator>Bittorrents.RO - Page 111 - TORRENTs.RO</dc:creator><author>Bittorrents.RO - Page 111 - TORRENTs.RO</author><description>&lt;p&gt;Pingback from &amp;nbsp;Bittorrents.RO - Page 111 - TORRENTs.RO&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7143972" width="1" height="1"&gt;</description></item><item><title>re: Gotcha: HTTP_X_FORWARDED_FOR returns multiple IP addresses</title><link>http://weblogs.asp.net/james_crowley/archive/2007/06/19/gotcha-http-x-forwarded-for-returns-multiple-ip-addresses.aspx#6498542</link><pubDate>Sat, 09 Aug 2008 11:34:42 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6498542</guid><dc:creator>tempest</dc:creator><author>tempest</author><description>&lt;p&gt;substr($_SERVER[&amp;#39;HTTP_X_FORWARDED_FOR&amp;#39;], 0, 15);&lt;/p&gt;
&lt;p&gt;if the first ip is the goal then this should suffice, no need for explode. But I am not at all clear if the goal the first IP or the last.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6498542" width="1" height="1"&gt;</description></item><item><title>re: Gotcha: HTTP_X_FORWARDED_FOR returns multiple IP addresses</title><link>http://weblogs.asp.net/james_crowley/archive/2007/06/19/gotcha-http-x-forwarded-for-returns-multiple-ip-addresses.aspx#6266491</link><pubDate>Tue, 10 Jun 2008 13:01:53 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6266491</guid><dc:creator>Scotty</dc:creator><author>Scotty</author><description>&lt;p&gt;Thanks Viral and Neokio. The added line from Viral looks good and works for me. I was looking for a function like explode... so this is perfect.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6266491" width="1" height="1"&gt;</description></item><item><title>re: Gotcha: HTTP_X_FORWARDED_FOR returns multiple IP addresses</title><link>http://weblogs.asp.net/james_crowley/archive/2007/06/19/gotcha-http-x-forwarded-for-returns-multiple-ip-addresses.aspx#6147753</link><pubDate>Thu, 01 May 2008 11:44:15 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6147753</guid><dc:creator>Viral</dc:creator><author>Viral</author><description>&lt;p&gt;:neokio&lt;/p&gt;
&lt;p&gt;instead of using first member from $_SERVER[&amp;#39;HTTP_X_FORWARDED_FOR&amp;#39;] retuning comma delimited value.&lt;/p&gt;
&lt;p&gt;shouldn&amp;#39;t we be using the last member of the array ?&lt;/p&gt;
&lt;p&gt;something like,&lt;/p&gt;
&lt;p&gt;$ip = $ip_array[ count($ip_array) - 1 ];&lt;/p&gt;
&lt;p&gt;???&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6147753" width="1" height="1"&gt;</description></item><item><title>re: Gotcha: HTTP_X_FORWARDED_FOR returns multiple IP addresses</title><link>http://weblogs.asp.net/james_crowley/archive/2007/06/19/gotcha-http-x-forwarded-for-returns-multiple-ip-addresses.aspx#3718624</link><pubDate>Mon, 03 Sep 2007 10:47:08 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:3718624</guid><dc:creator>neokio</dc:creator><author>neokio</author><description>&lt;p&gt;i ran into this about a year ago, and wrote this snippet as a workaround. Only tested it with a few proxies (Google translate, etc.), so no guarantees...&lt;/p&gt;
&lt;p&gt;		if (!empty($_SERVER[&amp;#39;HTTP_X_FORWARDED_FOR&amp;#39;]))&lt;/p&gt;
&lt;p&gt;			$ip = $_SERVER[&amp;#39;HTTP_X_FORWARDED_FOR&amp;#39;]; &lt;/p&gt;
&lt;p&gt;		else&lt;/p&gt;
&lt;p&gt;			$ip = $_SERVER[&amp;#39;REMOTE_ADDR&amp;#39;];&lt;/p&gt;
&lt;p&gt;		// &amp;nbsp;When viewed through an anonymous proxy, the address string&lt;/p&gt;
&lt;p&gt;		//	contans multiple ip#s separated hy commas. This fixes that.&lt;/p&gt;
&lt;p&gt;		$ip_array = explode(&amp;quot;,&amp;quot;, $ip);&lt;/p&gt;
&lt;p&gt;		$ip = $ip_array[0];&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=3718624" width="1" height="1"&gt;</description></item><item><title>re: Gotcha: HTTP_X_FORWARDED_FOR returns multiple IP addresses</title><link>http://weblogs.asp.net/james_crowley/archive/2007/06/19/gotcha-http-x-forwarded-for-returns-multiple-ip-addresses.aspx#3103345</link><pubDate>Wed, 11 Jul 2007 13:39:44 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:3103345</guid><dc:creator>jspurlin</dc:creator><author>jspurlin</author><description>&lt;p&gt;In which order is the comma delimited list returned?. For example, if I am trying to get &amp;quot;the&amp;quot; original ip, is it first in the list (always)?&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=3103345" width="1" height="1"&gt;</description></item><item><title>re: Gotcha: HTTP_X_FORWARDED_FOR returns multiple IP addresses</title><link>http://weblogs.asp.net/james_crowley/archive/2007/06/19/gotcha-http-x-forwarded-for-returns-multiple-ip-addresses.aspx#2940169</link><pubDate>Tue, 26 Jun 2007 10:36:04 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:2940169</guid><dc:creator>Boris Yeltsin's Zombie</dc:creator><author>Boris Yeltsin's Zombie</author><description>&lt;p&gt;Damn. I&amp;#39;ve written apps using this property and never knew it could send more than one IP. Thanks for the heads-up :)&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=2940169" width="1" height="1"&gt;</description></item><item><title>re: Gotcha: HTTP_X_FORWARDED_FOR returns multiple IP addresses</title><link>http://weblogs.asp.net/james_crowley/archive/2007/06/19/gotcha-http-x-forwarded-for-returns-multiple-ip-addresses.aspx#2908565</link><pubDate>Sun, 24 Jun 2007 00:10:20 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:2908565</guid><dc:creator>Kim</dc:creator><author>Kim</author><description>&lt;p&gt;Thank you James for solving this problem. We will update the source codes in IP2Location.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=2908565" width="1" height="1"&gt;</description></item></channel></rss>