http-shield #

A request filter that matches known exploit patterns in the request target, selected headers and the start of the body. Run it in detect mode first, review the matches, then turn on blocking where it fits the application. It is off by default.

Source: our repository on GitHub

Directives

shield #

syntax: shield 1 arg;  ·  context: http, server, location

http, server, location

shield_allow #

syntax: shield_allow 1+ args;  ·  context: http, server, location

http, server, location

shield_ban #

syntax: shield_ban 1+ args;  ·  context: http, server, location

http, server, location

shield_ban_status #

syntax: shield_ban_status 1 arg;  ·  context: location

Optional key=peer\|forwarded and repeatable trusted=<addr\|CIDR> — see Banning behind a proxy. | | shield_ban_status | location | — | Serve a ban or stats zone. | | shield_ban_status_format | location | json | json or prometheus — select JSON or negotiated metrics output.

shield_ban_status_format #

syntax: shield_ban_status_format 1 arg (enum);  ·  context: location

Optional key=peer\|forwarded and repeatable trusted=<addr\|CIDR> — see Banning behind a proxy. | | shield_ban_status | location | — | Serve a ban or stats zone. | | shield_ban_status_format | location | json | json or prometheus — select JSON or negotiated metrics output.

shield_ban_zone #

syntax: shield_ban_zone 1 arg;  ·  context: http

See Hit log. | | shield_stats_zone | http | — | <name> <size>; see below. | | shield_ban_zone | http | — | Define a shared-memory zone name:size (e.g.

shield_body #

syntax: shield_body on | off (on/off flag);  ·  context: http, server, location

http, server, location

shield_body_strict #

syntax: shield_body_strict on | off (on/off flag);  ·  context: http, server, location

http, server, location

shield_cve #

syntax: shield_cve 1+ args;  ·  context: http, server, location

http, server, location

shield_gzip #

syntax: shield_gzip on | off (on/off flag);  ·  context: http, server, location

http, server, location

shield_log #

syntax: shield_log 1 arg;  ·  context: http, server, location

http, server, location

shield_max_body #

syntax: shield_max_body 1 arg (size (k/m/g));  ·  context: http, server, location

http, server, location

shield_max_encoded_body #

syntax: shield_max_encoded_body 1 arg (size (k/m/g));  ·  context: http, server, location

http, server, location

shield_skip #

syntax: shield_skip 1+ args;  ·  context: http, server, location

http, server, location

shield_stats_zone #

syntax: shield_stats_zone 2 args;  ·  context: http

See Hit log. | | shield_stats_zone | http | — | <name> <size>; see below. | | shield_ban_zone | http | — | Define a shared-memory zone name:size (e.g.

shield_status #

syntax: shield_status 1 arg;  ·  context: http, server, location

http, server, location

Example

http {
    shield detect;
    shield_body on;                 # default on
    shield_max_body 8k;              # inspected prefix, not an upload limit
    shield_log /var/log/nginx/shield.json;
    shield_stats_zone shield_metrics 64k;

    server {
        listen 8080;

        location / {
            proxy_pass http://127.0.0.1:9000;
        }

        location = /shield-metrics {
            shield off;
            shield_ban_status shield_metrics;
            shield_ban_status_format prometheus;
            allow 127.0.0.1;
            deny all;
        }
    }
}

↑ back to index