Skip to content

Commit da35e09

Browse files
committed
README: revisited configuration directives section
1 parent f730ff6 commit da35e09

File tree

1 file changed

+76
-44
lines changed

1 file changed

+76
-44
lines changed

README.md

Lines changed: 76 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -36,62 +36,94 @@ http://wiki.nginx.org/3rdPartyModules
3636

3737
# Usage
3838

39-
ModSecurity for nginx extends your nginx configuration directives. It adds four
40-
new directives and they are:
39+
ModSecurity for nginx extends your nginx configuration directives.
40+
It adds four new directives and they are:
4141

42-
modsecurity [On|Off] - This directive turns on or off ModSecurity functionality. Note that
43-
this configuration directive is no longer related to the SecRule state. Instead, it now serves solely as an nginx flag to enable or disable the module.
42+
#### modsecurity
43+
----------------
4444

45-
modsecurity_rules_file [<path to rules file>] - This directive indicates the location of the modsecurity configuration file.
45+
**syntax:** *modsecurity on | off*
4646

47-
modsecurity_rules_remote [server-key] [<url to rules>] - This directive is used to indicate from where (on the internet) a modsecurity configuration file will be downloaded. It also specifies the key that will be used to authenticate to that server.
47+
**context:** *http, server, location*
4848

49-
modsecurity_rules [<modsecurity rule>] - This directive allows for the direct inclusion of a ModSecurity rule into the nginx configuration.
49+
**default:** *off*
5050

51-
### Usage example: injecting rules within nginx configuration
52-
```
53-
...
54-
modsecurity on;
55-
location / {
56-
modsecurity_rules '
57-
SecRuleEngine On
58-
SecDebugLog /tmp/modsec_debug.log
59-
SecDebugLogLevel 9
60-
SecRule ARGS "@contains test" "id:1,phase:2,t:trim,block"
61-
';
51+
Turns on or off ModSecurity functionality.
52+
Note that this configuration directive is no longer related to the SecRule state.
53+
Instead, it now serves solely as an nginx flag to enable or disable the module.
54+
55+
#### modsecurity_rules_file
56+
---------------------------
57+
58+
**syntax:** *modsecurity_rules_file &lt;path to rules file&gt;*
59+
60+
**context:** *http, server, location*
61+
62+
**default:** *no*
63+
64+
Specifies the location of the modsecurity configuration file, e.g.:
65+
66+
```nginx
67+
server {
68+
modsecurity on;
69+
location / {
70+
root /var/www/html;
71+
modsecurity_rules_file /etc/my_modsecurity_rules.conf;
72+
}
6273
}
63-
...
6474
```
6575

66-
### Usage example: loading rules from a file and injecting specific configurations per directory/alias
67-
```
68-
...
69-
modsecurity on;
70-
location / {
71-
root /var/www/html;
72-
modsecurity_rules_file /etc/my_modsecurity_rules.conf;
73-
}
74-
location /ops {
75-
root /var/www/html/opts;
76-
modsecurity_rules '
77-
SecRuleEngine On
78-
SecDebugLog /tmp/modsec_debug.log
79-
SecDebugLogLevel 9
80-
SecRuleRemoveById 10
81-
';
76+
#### modsecurity_rules_remote
77+
-----------------------------
78+
79+
**syntax:** *modsecurity_rules_remote &lt;key&gt; &lt;URL to rules&gt;*
80+
81+
**context:** *http, server, location*
82+
83+
**default:** *no*
84+
85+
Specifies from where (on the internet) a modsecurity configuration file will be downloaded.
86+
It also specifies the key that will be used to authenticate to that server:
87+
88+
```nginx
89+
server {
90+
modsecurity on;
91+
location / {
92+
root /var/www/html;
93+
modsecurity_rules_remote my-server-key https://my-own-server/rules/download;
94+
}
8295
}
83-
...
8496
```
8597

86-
### Usage example: loading rules from a remote server
87-
```
88-
...
89-
modsecurity on;
90-
location / {
91-
root /var/www/html;
92-
modsecurity_rules_remote my-server-key https://my-own-server/rules/download;
98+
#### modsecurity_rules
99+
----------------------
100+
101+
**syntax:** *modsecurity_rules &lt;modsecurity rule&gt;*
102+
103+
**context:** *http, server, location*
104+
105+
**default:** *no*
106+
107+
Allows for the direct inclusion of a ModSecurity rule into the nginx configuration.
108+
The following example is loading rules from a file and injecting specific configurations per directory/alias:
109+
110+
```nginx
111+
server {
112+
modsecurity on;
113+
location / {
114+
root /var/www/html;
115+
modsecurity_rules_file /etc/my_modsecurity_rules.conf;
116+
}
117+
location /ops {
118+
root /var/www/html/opts;
119+
modsecurity_rules '
120+
SecRuleEngine On
121+
SecDebugLog /tmp/modsec_debug.log
122+
SecDebugLogLevel 9
123+
SecRuleRemoveById 10
124+
';
125+
}
93126
}
94-
...
95127
```
96128

97129

0 commit comments

Comments
 (0)