diff --git a/src/ngx_pagespeed.cc b/src/ngx_pagespeed.cc index 8487f8ab6b..97f07d98ce 100644 --- a/src/ngx_pagespeed.cc +++ b/src/ngx_pagespeed.cc @@ -3019,13 +3019,17 @@ ngx_int_t ps_preaccess_handler(ngx_http_request_t* r) { ph = cmcf->phase_engine.handlers; i = r->phase_handler; + // move handlers before try_files && content phase + // As of nginx 1.13.4 we will be right before the try_files module + #if (nginx_version < 1013004) while (ph[i + 1].checker != ngx_http_core_try_files_phase && ph[i + 1].checker != ngx_http_core_content_phase) { ph[i] = ph[i + 1]; ph[i].next--; i++; } + #endif // insert ps phase handler ph[i].checker = ps_phase_handler; @@ -3081,8 +3085,16 @@ ngx_int_t ps_init(ngx_conf_t* cf) { ngx_http_core_main_conf_t* cmcf = static_cast( ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module)); + int phase = NGX_HTTP_PRECONTENT_PHASE; + + // As of nginx 1.13.4, try_files has changed. +#if (nginx_version < 1013004) + phase = NGX_HTTP_PREACCESS_PHASE; +#endif + ngx_http_handler_pt* h = static_cast( - ngx_array_push(&cmcf->phases[NGX_HTTP_PREACCESS_PHASE].handlers)); + ngx_array_push(&cmcf->phases[phase].handlers)); + if (h == NULL) { return NGX_ERROR; } diff --git a/testing-dependencies/nginx b/testing-dependencies/nginx index 6917d29d40..c556874e17 160000 --- a/testing-dependencies/nginx +++ b/testing-dependencies/nginx @@ -1 +1 @@ -Subproject commit 6917d29d409b187d440d8e5012a1353398e3a365 +Subproject commit c556874e174ff5b93a24976ed7032def2e8670c6