WordPress: How to use Nginx to obtain the user’s real IP after the website is installed with CloudFlare

888u

Last update at :2024-07-07,Edit by888u

Solve the problem of how to use Nginx to obtain the user’s real IP after the WordPress website Pagoda Panel is installed with CloudFlare’s CDN. If you are using the Pagoda Panel to manage your server, your site is likely to use proxy domain services such as CloudFlare, Sucuri, and Nginx. . They replace your user's IP address with the CDN's IP address. If the server the site is running on is not configured correctly, which often happens, all users will be given the same IP address. This also applies to bots and hackers. Therefore, locking one user will cause everyone else to be locked out. You can add 2 lines of code to the Nginx settings to get the user's real access IP, identify the IP source through the code and handle them correctly.

Copy set_real_ip_from 0.0.0.0/0;
real_ip_header X-Forwarded-For;

How to place the code? If we are using the Pagoda Nginx version, we can solve it by opening the configuration file in "Software Management" > "Running Environment" > "Nginx" and adding the above code after http{ }. As shown below

After saving, click Reload configuration to take effect.

After setting this, you can obtain the user's real access IP.

Recommended site searches: cloud server rental, server space rental, how to build a server, European server, Hong Kong proxy server, dynamic IP vps, free website space, Chinese IP segment, mainland China domain name, mainland China free space,

p>

WordPress: How to use Nginx to obtain the user’s real IP after the website is installed with CloudFlare

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码