Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

Showing the real client ip (behind nat) - HELP!

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
6 posts • Page 1 of 1
abdullakh
Posts: 3
Joined: Wed Oct 14, 2015 10:31 pm

Showing the real client ip (behind nat) - HELP!
  • Quote

Post by abdullakh » Thu Oct 15, 2015 1:01 pm

Hello,

I am having a server which is behind nat (mikortik router) the client ip in the apache and nginx showing the mikortik router which is 192.168.0.254 rather than the client IP.
<?php
echo $_SERVER['REMOTE_ADDR'];
?>

I have installed many modules in the apache such as remote-ip... but no lucky.

I have forwarded the domain via cloudflare and I can take the real visitor ip, and it is shows via $_SERVER['HTTP_CF_CONNECTING_IP']

The question now how $_SERVER['HTTP_CF_CONNECTING_IP'] is working? I want to make something like this without using cloudflare.

May you help?
Top

andrex
Posts: 1
Joined: Fri Jul 03, 2015 4:22 pm

Re: Showing the real client ip (behind nat) - HELP!
  • Quote

Post by andrex » Fri Oct 16, 2015 5:11 am

That's because you are using NGINX as proxy, so Apache sees any petition with the server's IP.

To find the "real" client IP you have to use

Code: Select all

<?php echo $_SERVER['HTTP_X_REAL_IP']; ?>
in PHP.

Hope this helps.

Regards.
Top

mike08
Posts: 160
Joined: Sat Jun 20, 2015 7:12 am

Os: Debian 6x
Web: apache + nginx
Re: Showing the real client ip (behind nat) - HELP!
  • Quote

Post by mike08 » Wed Oct 28, 2015 11:52 am

Additionaly, I have tried another config on my Debian 7, you can modify the file:

Code: Select all

/etc/apache2/mods-enabled/rpaf.conf
And replace it with this conf

Code: Select all

<IfModule rpaf_module>
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 192.168.1.150 192.168.1.151 192.168.1.152
RPAFheader X-Forwarded-For
</IfModule>
Modify the ips for the one you use on your server as proxy.
Then restart apache from within VestaCP admin area this should show clients real IP instead of the nginx proxy.
Top

rnbmafia
Posts: 14
Joined: Sat Apr 18, 2015 4:38 pm

Re: Showing the real client ip (behind nat) - HELP!
  • Quote

Post by rnbmafia » Thu Nov 12, 2015 9:52 pm

nginx.conf



# Proxy settings
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_header Set-Cookie;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
Top

xandehenrique
Posts: 26
Joined: Mon Jan 04, 2016 3:09 pm

Re: Showing the real client ip (behind nat) - HELP!
  • Quote

Post by xandehenrique » Wed Jan 27, 2016 9:28 pm

Someone managed to solve this problem of IP visitors?
Top

xandehenrique
Posts: 26
Joined: Mon Jan 04, 2016 3:09 pm

Re: Showing the real client ip (behind nat) - HELP!
  • Quote

Post by xandehenrique » Wed Jan 27, 2016 9:33 pm

andrex wrote:That's because you are using NGINX as proxy, so Apache sees any petition with the server's IP.

To find the "real" client IP you have to use

Code: Select all

<?php echo $_SERVER['HTTP_X_REAL_IP']; ?>
in PHP.

Hope this helps.

Regards.

Hello friend, in which file I see this setting?
Top


Post Reply
  • Print view

6 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password