Skip to content

Commit 6377bcd

Browse files
committed
Do not run redirectionio when not in main request
1 parent 1ee426d commit 6377bcd

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/ngx_http_redirectionio_module.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ static ngx_int_t ngx_http_redirectionio_create_ctx_handler(ngx_http_request_t *r
168168
ngx_http_redirectionio_ctx_t *ctx;
169169
ngx_http_redirectionio_conf_t *conf;
170170

171+
// Disallow in sub request
172+
if (r != r->main) {
173+
return NGX_DECLINED;
174+
}
175+
171176
conf = ngx_http_get_module_loc_conf(r, ngx_http_redirectionio_module);
172177

173178
if (conf->enable == NGX_HTTP_REDIRECTIONIO_OFF) {
@@ -214,6 +219,11 @@ static ngx_int_t ngx_http_redirectionio_redirect_handler(ngx_http_request_t *r)
214219
ngx_int_t status;
215220
unsigned short redirect_status_code;
216221

222+
// Disallow in sub request
223+
if (r != r->main) {
224+
return NGX_DECLINED;
225+
}
226+
217227
conf = ngx_http_get_module_loc_conf(r, ngx_http_redirectionio_module);
218228

219229
if (conf->enable == NGX_HTTP_REDIRECTIONIO_OFF) {
@@ -298,6 +308,11 @@ static ngx_int_t ngx_http_redirectionio_log_handler(ngx_http_request_t *r) {
298308
ngx_http_redirectionio_ctx_t *ctx;
299309
ngx_http_redirectionio_log_t *log;
300310

311+
// Disallow in sub request
312+
if (r != r->main) {
313+
return NGX_DECLINED;
314+
}
315+
301316
conf = ngx_http_get_module_loc_conf(r, ngx_http_redirectionio_module);
302317

303318
if (conf->enable == NGX_HTTP_REDIRECTIONIO_OFF) {

0 commit comments

Comments
 (0)