This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12916|Reply: 0

nginx obtains real access IP logs from 360 Website Guard CDN

[Copy link]
Posted on 7/10/2016 10:08:48 AM | | | |


After using the CDN acceleration tool, if we want to view the website logs, we will see that all the recorded IPs are the IP addresses of the CDN nodes, not the user's real user IP records.
In this way, if we need to perform log analysis, it is more difficult, Lao Jiang is more commonly used is the Nginx environment, so how can we set up the Nginx environment, while we want to use CDN to accelerate, the website logs can also see the real IP address.
First, modify the Nginx.conf file
/usr/local/nginx/conf/
Generally, there is an nginx.conf file in this directory, and we need to add the following script in http:
log_format  access  '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" ';
Set the log format, if you don't want to understand what it means, just add it, I tested it without any problem.
Second, modify the current site format log
/usr/local/nginx/conf/vhost/
Check the current site's configuration file directory and modify it
access_log /www/wwwlogs/itbulu.com_nginx.log access;
The red part is what we need to modify/add.
Third, restart Nginx
service nginx reload
If you restart Nginx, if you see Success, it means that there is no problem with the nginx configuration.
In summary, many of our friends here may not use the same Nginx environment, but the meaning is probably the same, we can modify it in a targeted manner. In this way, while we use CDN acceleration, we can also see real IP access records in the website logs.
The following is the configuration, and the obtained IP is the real IP of the user

Attach your own profile









Previous:Write to you who attack the website, it's boring!
Next:Memcache Unauthorized Access Vulnerability Remediation Scenario
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com