Support » Plugin: NinjaFirewall (WP Edition) - Advanced Security » FIxing IP logging with Varnish reverse proxy

  • Resolved carlosesposito

    (@carlosesposito)


    Hi,

    I’m running WordPress on Linux with Apache and the Varnish reverse proxy. My NinjaFirewall log displays the internal IP 127.0.0.1 for every entry, so I need to fix that.
    I’ve put the .htninja file in the parent of the document root folder, no problem with that. The Ninja dashboard has acknowledged that the file is there and displays the correct status.
    However, I don’t know what code I need to put on that file for it to work. The sample code that is commented on the .htninja file (and explained on the .htninja reference page) doesn’t seem to apply to my case. Or does it?
    I’m not using Load Balancing nor any CDN. Just the Varnish 6.03 reverse proxy.

    Thanks for your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author nintechnet

    (@nintechnet)

    By default, Varnish should forward the real IP in the HTTP_X_FORWARDED_FOR header:

    <?php
    /*
     +====================================================================+
     | NinjaFirewall optional configuration file                          |
     |                                                                    |
     | See: https://nintechnet.com/ninjafirewall/wp-edition/help/?htninja |
     +====================================================================+
    */
    
    if (! empty($_SERVER["HTTP_X_FORWARDED_FOR"]) &&
     filter_var($_SERVER["HTTP_X_FORWARDED_FOR"],FILTER_VALIDATE_IP)) {
    	$_SERVER["REMOTE_ADDR"] = $_SERVER["HTTP_X_FORWARDED_FOR"];
    }
    

    Thanks, the issue is now solved.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.