www/nginx: Add Possibility to Disable User Agent Based Blocks (#934)

* Add Possibility to Disable Bot Protection

* fix merge issue
This commit is contained in:
fzoske
2018-11-13 19:38:32 +01:00
committed by Fabian Franz BSc
parent 7a49be585c
commit 1bcb29f48f
3 changed files with 14 additions and 1 deletions
@@ -79,6 +79,13 @@
<advanced>true</advanced>
<help>Blocks files like .htaccess files or other files not intended for the public.</help>
</field>
<field>
<id>httpserver.disable_bot_protection</id>
<label>Disable Bot Protection</label>
<type>checkbox</type>
<advanced>false</advanced>
<help>Blocks the request when a possibly bad bot is detected and adds the originating IP to the managed firewall alias for permanent blocking.</help>
</field>
<field>
<id>httpserver.ip_acl</id>
<label>IP ACL</label>
@@ -1,6 +1,6 @@
<model>
<mount>//OPNsense/Nginx</mount>
<version>1.1.2</version>
<version>1.1.3</version>
<description>nginx web server, reverse proxy and waf</description>
<items>
<general>
@@ -558,6 +558,10 @@
<default>0</default>
<Required>Y</Required>
</block_nonpublic_data>
<disable_bot_protection type="BooleanField">
<default>0</default>
<Required>Y</Required>
</disable_bot_protection>
<naxsi_extensive_log type="BooleanField">
<default>0</default>
<Required>Y</Required>
@@ -130,6 +130,7 @@ server {
root /var/etc/acme-client/challenges;
}
{% endif %}
{% if server.disable_bot_protection is not defined or server.disable_bot_protection != '1' %}
# block based on User Agents - stuff I have found over the years in my server log
if ($http_user_agent ~* Python-urllib|Nmap|python-requests|libwww-perl|MJ12bot|Jorgee|fasthttp|libwww|Telesphoreo|A6-Indexer|ltx71|okhttp|ZmEu|sqlmap|LMAO/2.0|ltx71|zgrab|Ronin/2.0|Hakai/2.0) {
return 418;
@@ -143,6 +144,7 @@ server {
{
return 418;
}
{% endif %}
{% if server.ip_acl is defined %}
{% set ip_acl = server.ip_acl %}
{% include "OPNsense/Nginx/ipacl.conf" %}