@@ -52,10 +52,10 @@ http {
52
52
listen 127.0.0.1:8080;
53
53
server_name s1;
54
54
55
- error_page 403 /403.html ;
55
+ error_page 403 /error ;
56
56
57
- location /403.html {
58
- root %%TESTDIR%%/http ;
57
+ location /error {
58
+ alias %%TESTDIR%%/error.html ;
59
59
internal;
60
60
}
61
61
@@ -64,11 +64,11 @@ http {
64
64
modsecurity_rules '
65
65
SecRuleEngine On
66
66
SecRule ARGS "@streq root" "id:10,phase:1,auditlog,status:403,deny"
67
- SecDebugLog %%TESTDIR%%/auditlog-debug-local .txt
67
+ SecDebugLog %%TESTDIR%%/auditlog-debug-location .txt
68
68
SecDebugLogLevel 9
69
69
SecAuditEngine RelevantOnly
70
70
SecAuditLogParts ABIJDEFHZ
71
- SecAuditLog %%TESTDIR%%/auditlog-local .txt
71
+ SecAuditLog %%TESTDIR%%/auditlog-location .txt
72
72
SecAuditLogType Serial
73
73
SecAuditLogStorageDir %%TESTDIR%%/
74
74
';
@@ -83,20 +83,20 @@ http {
83
83
modsecurity_rules '
84
84
SecRuleEngine On
85
85
SecRule ARGS "@streq root" "id:10,phase:1,auditlog,status:403,deny"
86
- SecDebugLog %%TESTDIR%%/auditlog-debug-global .txt
86
+ SecDebugLog %%TESTDIR%%/auditlog-debug-server .txt
87
87
SecDebugLogLevel 9
88
88
SecAuditEngine RelevantOnly
89
89
SecAuditLogParts ABIJDEFHZ
90
- SecAuditLog %%TESTDIR%%/auditlog-global .txt
90
+ SecAuditLog %%TESTDIR%%/auditlog-server .txt
91
91
SecAuditLogType Serial
92
92
SecAuditLogStorageDir %%TESTDIR%%/
93
93
';
94
94
95
- error_page 403 /403.html ;
95
+ error_page 403 /error ;
96
96
97
- location /403.html {
97
+ location /error {
98
98
modsecurity off;
99
- root %%TESTDIR%%/http ;
99
+ alias %%TESTDIR%%/error.html ;
100
100
internal;
101
101
}
102
102
@@ -107,11 +107,10 @@ http {
107
107
EOF
108
108
109
109
my $index_txt = "This is the index page.";
110
- my $custom_txt = "This is a custom error page.";
111
-
112
110
$t->write_file("/index.html", $index_txt);
113
- mkdir($t->testdir() . '/http');
114
- $t->write_file("/http/403.html", $custom_txt);
111
+
112
+ my $error_txt = "This is a custom error page.";
113
+ $t->write_file("/error.html", $error_txt);
115
114
116
115
$t->run();
117
116
$t->plan(10);
@@ -126,39 +125,39 @@ my $t3;
126
125
my $t4;
127
126
128
127
# Performing requests to a server with ModSecurity enabled at location context
129
- $t1 = http_get_host('s1', '/index.html ?what=root');
130
- $t2 = http_get_host('s1', '/index.html ?what=other');
128
+ $t1 = http_get_host('s1', '/?what=root');
129
+ $t2 = http_get_host('s1', '/?what=other');
131
130
132
131
# Performing requests to a server with ModSecurity enabled at server context
133
- $t3 = http_get_host('s2', '/index.html ?what=root');
134
- $t4 = http_get_host('s2', '/index.html ?what=other');
132
+ $t3 = http_get_host('s2', '/?what=root');
133
+ $t4 = http_get_host('s2', '/?what=other');
135
134
136
- my $local = do {
135
+ my $auditlog_location = do {
137
136
local $/ = undef;
138
- open my $fh, "<", "$d/auditlog-local .txt"
137
+ open my $fh, "<", "$d/auditlog-location .txt"
139
138
or die "could not open: $!";
140
139
<$fh>;
141
140
};
142
141
143
- my $global = do {
142
+ my $auditlog_server = do {
144
143
local $/ = undef;
145
- open my $fh, "<", "$d/auditlog-global .txt"
144
+ open my $fh, "<", "$d/auditlog-server .txt"
146
145
or die "could not open: $!";
147
146
<$fh>;
148
147
};
149
148
150
- like($t1, qr/$custom_txt /, 'ModSecurity at location / root');
149
+ like($t1, qr/$error_txt /, 'ModSecurity at location / root');
151
150
like($t2, qr/$index_txt/, 'ModSecurity at location / other');
152
- like($local , qr/what=root/, 'ModSecurity at location / root present in auditlog');
153
- unlike($local , qr/what=other/, 'ModSecurity at location / other not present in auditlog');
151
+ like($auditlog_location , qr/what=root/, 'ModSecurity at location / root present in auditlog');
152
+ unlike($auditlog_location , qr/what=other/, 'ModSecurity at location / other not present in auditlog');
154
153
155
- like($t3, qr/$custom_txt /, 'ModSecurity at server / root');
154
+ like($t3, qr/$error_txt /, 'ModSecurity at server / root');
156
155
like($t4, qr/$index_txt/, 'ModSecurity at server / other');
157
- like($global , qr/what=root/, 'ModSecurity at server / root present in auditlog');
158
- unlike($global , qr/what=other/, 'ModSecurity at server / other not present in auditlog');
156
+ like($auditlog_server , qr/what=root/, 'ModSecurity at server / root present in auditlog');
157
+ unlike($auditlog_server , qr/what=other/, 'ModSecurity at server / other not present in auditlog');
159
158
160
- like($local , qr/Access denied with code 403/, 'ModSecurity at location / 403 in auditlog');
161
- like($global , qr/Access denied with code 403/, 'ModSecurity at server / 403 in auditlog');
159
+ like($auditlog_location , qr/Access denied with code 403/, 'ModSecurity at location / 403 in auditlog');
160
+ like($auditlog_server , qr/Access denied with code 403/, 'ModSecurity at server / 403 in auditlog');
162
161
163
162
###############################################################################
164
163
0 commit comments