WordPress can not get the solution of real IP when CDN acceleration is enabled

WordPress can not get the solution of real IP when CDN acceleration is enabled

 September
2017-08-19 / 1 comments / 7033 reading / Checking for inclusion


Now many webmasters use CDN acceleration, one is to bring users the fastest browsing experience, the second is to protect the source station. Just inadvertently found, open WordPress comments, comment IP are basically those several, through the investigation, all are cloud CDN node IP address. If you encounter malicious comments, you can't intercept CDN IP directly. So how to display the comment real IP after CDN is enabled? Baidu to a code, collection

Open the site and directory / wp-config.php file and add the code to the second line <? PHP

 /**Using CDN to obtain IP*/ if(isset($_ SERVER['HTTP_ X_ FORWARDED_ FOR'])) { $list = explode(',',$_ SERVER['HTTP_ X_ FORWARDED_ FOR']); $_ SERVER['REMOTE_ ADDR'] = $list[0]; }

The code comes from the network

This comment IP is normal.

zero

Comments (1)

cancel
  1.  head portrait
    Yao Yao
    Windows 10 · FireFox

    :: huaji:mojinghuaji :: my will report an error

    reply