ninjafirewall
Last commit date
images
1 month ago
languages
11 months ago
lib
1 month ago
static
1 month ago
.htaccess
7 years ago
.htninja.sample
2 years ago
LICENSE.TXT
13 years ago
index.html
12 years ago
ninjafirewall.php
1 month ago
readme.txt
3 weeks ago
uninstall.php
1 year ago
.htninja.sample
90 lines
| 1 | <?php |
| 2 | /* |
| 3 | +============================================================================================+ |
| 4 | | NinjaFirewall optional configuration file | |
| 5 | | | |
| 6 | | See: https://blog.nintechnet.com/ninjafirewall-wp-edition-the-htninja-configuration-file/ | |
| 7 | | | |
| 8 | +============================================================================================+ |
| 9 | */ |
| 10 | |
| 11 | // To tell NinjaFirewall where you moved your WP config file, |
| 12 | // use the '$wp_config' variable : |
| 13 | // $wp_config = '/foo/bar/wp-config.php'; |
| 14 | |
| 15 | |
| 16 | |
| 17 | // Users of Cloudflare CDN: |
| 18 | // if (! empty($_SERVER["HTTP_CF_CONNECTING_IP"]) && |
| 19 | // filter_var($_SERVER["HTTP_CF_CONNECTING_IP"], FILTER_VALIDATE_IP) ) { |
| 20 | // $_SERVER["REMOTE_ADDR"] = $_SERVER["HTTP_CF_CONNECTING_IP"]; |
| 21 | // } |
| 22 | |
| 23 | |
| 24 | // Users of Incapsula CDN: |
| 25 | // if (! empty($_SERVER["HTTP_INCAP_CLIENT_IP"]) && |
| 26 | // filter_var($_SERVER["HTTP_INCAP_CLIENT_IP"], FILTER_VALIDATE_IP) ) { |
| 27 | // $_SERVER["REMOTE_ADDR"] = $_SERVER["HTTP_INCAP_CLIENT_IP"]; |
| 28 | // } |
| 29 | |
| 30 | |
| 31 | // Whitelist/blacklist whatever you want: |
| 32 | // |
| 33 | // Return codes: |
| 34 | // 'ALLOW' == Allow and stop filtering (whitelist). |
| 35 | // 'BLOCK' == Reject immediately (blacklist). |
| 36 | // |
| 37 | // Any other return code will be ignored |
| 38 | // |
| 39 | // Note that if you use 'ALLOW'/'BLOCK', nothing will be written |
| 40 | // to the firewall log. |
| 41 | |
| 42 | // Whitelist single IP 1.2.3.4: |
| 43 | // if ( $_SERVER["REMOTE_ADDR"] == '1.2.3.4' ) { |
| 44 | // return 'ALLOW'; // whitelist |
| 45 | // } |
| 46 | |
| 47 | // Whitelist IPs 1.1.1.1, 2.2.2.2 and 3.3.3.3: |
| 48 | // $ip_array = array( '1.1.1.1' , '2.2.2.2' , '3.3.3.3' ); |
| 49 | // if ( in_array( $_SERVER["REMOTE_ADDR"], $ip_array ) ) { |
| 50 | // return 'ALLOW'; // whitelist |
| 51 | // } |
| 52 | |
| 53 | // Whitelist all IPs from 1.1.1.1 to 1.1.1.255: |
| 54 | // if ( preg_match( '/^1\.1\.1\.\d+$/', $_SERVER["REMOTE_ADDR"] ) ) { |
| 55 | // return 'ALLOW'; // whitelist |
| 56 | // } |
| 57 | |
| 58 | // Blacklist single IP 1.2.3.4: |
| 59 | // if ( $_SERVER["REMOTE_ADDR"] == '1.2.3.4' ) { |
| 60 | // return 'BLOCK'; // blacklist |
| 61 | // } |
| 62 | |
| 63 | // Blacklist IPs 1.1.1.1, 2.2.2.2 and 3.3.3.3: |
| 64 | // $ip_array = array( '1.1.1.1' , '2.2.2.2' , '3.3.3.3' ); |
| 65 | // if ( in_array( $_SERVER["REMOTE_ADDR"], $ip_array ) ) { |
| 66 | // return 'BLOCK'; // blacklist |
| 67 | // } |
| 68 | |
| 69 | // Blacklist all IPs from 1.1.1.1 to 1.1.1.255: |
| 70 | // if ( preg_match( '/^1\.1\.1\.\d+$/', $_SERVER["REMOTE_ADDR"] ) ) { |
| 71 | // return 'BLOCK'; // blacklist |
| 72 | // } |
| 73 | |
| 74 | |
| 75 | // Do not filter any HTTP request sent to a script located inside the /myfolder/ directory: |
| 76 | // if (strpos($_SERVER['SCRIPT_FILENAME'], '/myfolder/') !== FALSE) { |
| 77 | // return 'ALLOW'; |
| 78 | // } |
| 79 | |
| 80 | // Advanced filtering : |
| 81 | // Block immediately a POST request if it contains a 'whatever' variable |
| 82 | // sent to a script named 'script.php' : |
| 83 | // if ( isset($_POST['whatever']) && strpos($_SERVER['SCRIPT_NAME'], 'script.php') !== FALSE ) { |
| 84 | // return 'BLOCK'; |
| 85 | // } |
| 86 | |
| 87 | |
| 88 | |
| 89 | // do not add anything below this line. |
| 90 |