Focus on cloud service provider activities
Notes on website operation and maintenance

How to set and obtain the real user IP address information after the website accesses the CDN

Generally, when we use the WordPress program, we can see the user's message information in the comment background, including the user's IP address. Of course, it also includes the logs we are using to view user log information. However, if we enable the CDN content distribution function, the IP address information obtained is the CDN IP address, and the real user information cannot be obtained, is there any way to achieve it?

A netizen mentioned this problem yesterday. He uses the Pagoda Panel Nginx WEB environment. After searching here, Lao Zuo found that there was a solution for this netizen, and finally it was solved. Here, Lao Zuo records the solution today so that users in need can use it.

 How to set and obtain the real user IP address information after the website accesses the CDN

This student uses the pagoda panel. We need to add code to the NGINX configuration file. Modify the configuration file to the HTTP location.

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

Add code.

Finally, restart the NGINX server and see if the log file is the correct user's real IP address. We just need to extract the latest IP search to see if it is our local address, because we are also accessing.

Vote for you
Domain name host preferential information push QQ group: six hundred and twenty-seven million seven hundred and seventy-five thousand four hundred and seventy-seven Get preferential promotion from merchants.
Like( two )
Do not reprint without permission: Lao Zuo's Notes » How to set and obtain the real user IP address information after the website accesses the CDN


Scan the code to follow the official account

Get more news about webmaster circle!
Entrepreneurship, operation and new knowledge