@@ -52,10 +52,10 @@ http {
5252 listen 127.0.0.1:8080;
5353 server_name s1;
5454
55- error_page 403 /403.html ;
55+ error_page 403 /error ;
5656
57- location /403.html {
58- root %%TESTDIR%%/http ;
57+ location /error {
58+ alias %%TESTDIR%%/error.html ;
5959 internal;
6060 }
6161
@@ -64,11 +64,11 @@ http {
6464 modsecurity_rules '
6565 SecRuleEngine On
6666 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
6868 SecDebugLogLevel 9
6969 SecAuditEngine RelevantOnly
7070 SecAuditLogParts ABIJDEFHZ
71- SecAuditLog %%TESTDIR%%/auditlog-local .txt
71+ SecAuditLog %%TESTDIR%%/auditlog-location .txt
7272 SecAuditLogType Serial
7373 SecAuditLogStorageDir %%TESTDIR%%/
7474 ';
@@ -83,20 +83,20 @@ http {
8383 modsecurity_rules '
8484 SecRuleEngine On
8585 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
8787 SecDebugLogLevel 9
8888 SecAuditEngine RelevantOnly
8989 SecAuditLogParts ABIJDEFHZ
90- SecAuditLog %%TESTDIR%%/auditlog-global .txt
90+ SecAuditLog %%TESTDIR%%/auditlog-server .txt
9191 SecAuditLogType Serial
9292 SecAuditLogStorageDir %%TESTDIR%%/
9393 ';
9494
95- error_page 403 /403.html ;
95+ error_page 403 /error ;
9696
97- location /403.html {
97+ location /error {
9898 modsecurity off;
99- root %%TESTDIR%%/http ;
99+ alias %%TESTDIR%%/error.html ;
100100 internal;
101101 }
102102
@@ -107,11 +107,10 @@ http {
107107EOF
108108
109109my $index_txt = " This is the index page." ;
110- my $custom_txt = " This is a custom error page." ;
111-
112110$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 );
115114
116115$t -> run();
117116$t -> plan(10);
@@ -126,39 +125,39 @@ my $t3;
126125my $t4 ;
127126
128127# 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' );
131130
132131# 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' );
135134
136- my $local = do {
135+ my $auditlog_location = do {
137136 local $/ = undef ;
138- open my $fh , " <" , " $d /auditlog-local .txt"
137+ open my $fh , " <" , " $d /auditlog-location .txt"
139138 or die " could not open: $! " ;
140139 <$fh >;
141140};
142141
143- my $global = do {
142+ my $auditlog_server = do {
144143 local $/ = undef ;
145- open my $fh , " <" , " $d /auditlog-global .txt"
144+ open my $fh , " <" , " $d /auditlog-server .txt"
146145 or die " could not open: $! " ;
147146 <$fh >;
148147};
149148
150- like($t1 , qr /$custom_txt / , ' ModSecurity at location / root' );
149+ like($t1 , qr /$error_txt / , ' ModSecurity at location / root' );
151150like($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' );
154153
155- like($t3 , qr /$custom_txt / , ' ModSecurity at server / root' );
154+ like($t3 , qr /$error_txt / , ' ModSecurity at server / root' );
156155like($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' );
159158
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' );
162161
163162# ##############################################################################
164163
0 commit comments