Method for obtaining the visitor's real IP in logs after enabling nginx proxy
Published: 2020-12-15
Windows Server Settings
If security software is installed on the server, it may cause the DLL for obtaining real IP logs to run abnormally, resulting in failure to obtain the real IP address.
The required steps depend on your IIS version. This operation applies to IIS 7 and later versions.
1. Download the plugin F5XForwardedFor.dll:http://download.west263.net/iis7-rewrite%E6%8F%92%E4%BB%B6/x_forwarded_for.rar

4. Add “ISAPI Filters”: double-click “ISAPI Filters” and click Add. Note: Do not add it at the site level.

5. Enter a name for the filter (no special requirements), select the DLL file path, and click OK. Add the two DLLs separately.


6. Restart the IIS server. After the configuration takes effect, check the IIS logs; the real IP address will be displayed after the 127.0.0.1 column.

Linux Server Settings
After using a third-party CDN, the address obtained by nginx on the server is the third-party CDN address. Modify the nginx configuration to obtain the real IP address.
Add the following two lines of code after http{
set_real_ip_from 0.0.0.0/0;
real_ip_header X-Forwarded-For;
Using BaoTa as an example
Log in to the BaoTa Panel backend >> Software Store >> Runtime Environment >> click the corresponding “Settings” on the right side of nginx >> in nginx management, click “Modify Configuration” on the left >> add the following two lines of code after http{, as shown below:

