Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
Extracting real visitor IP
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Logic" data-source="post: 387563" data-attributes="member: 12691"><p>Hello,</p><p></p><p>So as most of you know, when using a reverse HTTP proxy, you need your provider to set its headers to send the visitors real IP address instead of your proxy IP address to prevent everyone's IP being your proxy's IP address. That being said, the typical code placed in <span style="font-family: 'Courier New'">global.php</span> to extract the visitors real IP address would be:</p><p></p><p>[CODE]</p><p>if(isset($_SERVER['HTTP_X_REAL_IP'])){ $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_REAL_IP'];}</p><p>[/CODE]</p><p></p><p>However, doing this doesn't allow anyone to login. So, I took it a bit further and created a file called <span style="font-family: 'Courier New'">ip.php </span><span style="font-family: 'Arial'">with the following code:</span></p><p><span style="font-family: 'Arial'">[CODE]</span></p><p><span style="font-family: 'Arial'"><?php</span></p><p><span style="font-family: 'Arial'">echo $_SERVER['REMOTE_ADDR'];</span></p><p><span style="font-family: 'Arial'">[/CODE]</span></p><p><span style="font-family: 'Arial'"></span></p><p><span style="font-family: 'Arial'">Upon visiting that page, it outputs my proxy IP address which is where the problem is. My proxy provider mentioned to use </span><span style="font-family: 'Courier New'">HTTP_X_FORWARDED_TO</span><span style="font-family: 'Arial'">, so I gave it a shot with the following code:</span></p><p><span style="font-family: 'Arial'">[CODE]</span></p><p><span style="font-family: 'Arial'">if(isset($_SERVER['HTTP_X_FORWARDED_TO'])){ $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_TO'];}</span></p><p><span style="font-family: 'Arial'">[/CODE]</span></p><p><span style="font-family: 'Arial'"></span></p><p><span style="font-family: 'Arial'">But by doing so, it lists the IP's as such:</span></p><p><span style="font-family: 'Arial'">[CODE]69.136.xxx.xxx,104.197.xxx.xx,104.192.xxx.xxx[/CODE]</span></p><p><span style="font-family: 'Arial'">With the first IP address listed, my IP address (real visitor IP address).</span></p><p><span style="font-family: 'Arial'"></span></p><p><span style="font-family: 'Arial'">So he mentioned with that then to grab the first word in the string (assuming the real IP address), explode string with " " delimiter, and grab the first element. I'm not really familiar with PHP but I happened to find something that would hopefully work in this case:</span></p><p>[CODE]</p><p>if (!isset($_SERVER[”REMOTE_ADDR”]) && isset($_SERVER[”HTTP_X_FORWARDED_FOR”]))</p><p>{</p><p>$IP = array_pop(explode(”,”,$_SERVER[”HTTP_X_FORWARDED_FOR”]));</p><p>}[/CODE]</p><p></p><p>But then again, it only extracts it down to just my proxy IP address. Ultimately, I've not found something that has successfully worked and would like some help. Sorry for the explaining but I want everyone to know the step-by-steps I took in attempts to resolve this. Yes, I'm currently using RevCMS as well.</p><p></p><p>Thank you!</p></blockquote><p></p>
[QUOTE="Logic, post: 387563, member: 12691"] Hello, So as most of you know, when using a reverse HTTP proxy, you need your provider to set its headers to send the visitors real IP address instead of your proxy IP address to prevent everyone's IP being your proxy's IP address. That being said, the typical code placed in [FONT=Courier New]global.php[/FONT] to extract the visitors real IP address would be: [CODE] if(isset($_SERVER['HTTP_X_REAL_IP'])){ $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_REAL_IP'];} [/CODE] However, doing this doesn't allow anyone to login. So, I took it a bit further and created a file called [FONT=Courier New]ip.php [/FONT][FONT=Arial]with the following code: [CODE] <?php echo $_SERVER['REMOTE_ADDR']; [/CODE] Upon visiting that page, it outputs my proxy IP address which is where the problem is. My proxy provider mentioned to use [/FONT][FONT=Courier New]HTTP_X_FORWARDED_TO[/FONT][FONT=Arial], so I gave it a shot with the following code: [CODE] if(isset($_SERVER['HTTP_X_FORWARDED_TO'])){ $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_TO'];} [/CODE] But by doing so, it lists the IP's as such: [CODE]69.136.xxx.xxx,104.197.xxx.xx,104.192.xxx.xxx[/CODE] With the first IP address listed, my IP address (real visitor IP address). So he mentioned with that then to grab the first word in the string (assuming the real IP address), explode string with " " delimiter, and grab the first element. I'm not really familiar with PHP but I happened to find something that would hopefully work in this case:[/FONT] [CODE] if (!isset($_SERVER[”REMOTE_ADDR”]) && isset($_SERVER[”HTTP_X_FORWARDED_FOR”])) { $IP = array_pop(explode(”,”,$_SERVER[”HTTP_X_FORWARDED_FOR”])); }[/CODE] But then again, it only extracts it down to just my proxy IP address. Ultimately, I've not found something that has successfully worked and would like some help. Sorry for the explaining but I want everyone to know the step-by-steps I took in attempts to resolve this. Yes, I'm currently using RevCMS as well. Thank you! [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
Extracting real visitor IP
Top