@@ -716,6 +716,10 @@ ngx_http_cache_purge_access_handler(ngx_http_request_t *r)
716716 return NGX_HTTP_FORBIDDEN ;
717717 }
718718
719+ if (cplcf -> handler == NULL ) {
720+ return NGX_HTTP_NOT_FOUND ;
721+ }
722+
719723 return cplcf -> handler (r );
720724}
721725
@@ -1184,11 +1188,10 @@ ngx_http_cache_purge_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
11841188 if (conf -> fastcgi .enable && clcf -> handler != NULL ) {
11851189 flcf = ngx_http_conf_get_module_loc_conf (cf , ngx_http_fastcgi_module );
11861190
1187- if (flcf -> upstream .cache
1188- && (flcf -> upstream .upstream || flcf -> fastcgi_lengths ))
1189- {
1191+ if (flcf -> upstream .upstream || flcf -> fastcgi_lengths ) {
11901192 conf -> conf = & conf -> fastcgi ;
1191- conf -> handler = ngx_http_fastcgi_cache_purge_handler ;
1193+ conf -> handler = flcf -> upstream .cache
1194+ ? ngx_http_fastcgi_cache_purge_handler : NULL ;
11921195 conf -> original_handler = clcf -> handler ;
11931196
11941197 clcf -> handler = ngx_http_cache_purge_access_handler ;
@@ -1204,11 +1207,10 @@ ngx_http_cache_purge_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
12041207 if (conf -> proxy .enable && clcf -> handler != NULL ) {
12051208 plcf = ngx_http_conf_get_module_loc_conf (cf , ngx_http_proxy_module );
12061209
1207- if (plcf -> upstream .cache
1208- && (plcf -> upstream .upstream || plcf -> proxy_lengths ))
1209- {
1210+ if (plcf -> upstream .upstream || plcf -> proxy_lengths ) {
12101211 conf -> conf = & conf -> proxy ;
1211- conf -> handler = ngx_http_proxy_cache_purge_handler ;
1212+ conf -> handler = plcf -> upstream .cache
1213+ ? ngx_http_proxy_cache_purge_handler : NULL ;
12121214 conf -> original_handler = clcf -> handler ;
12131215
12141216 clcf -> handler = ngx_http_cache_purge_access_handler ;
@@ -1224,13 +1226,11 @@ ngx_http_cache_purge_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
12241226 if (conf -> scgi .enable && clcf -> handler != NULL ) {
12251227 slcf = ngx_http_conf_get_module_loc_conf (cf , ngx_http_scgi_module );
12261228
1227- if (slcf -> upstream .cache
1228- && (slcf -> upstream .upstream || slcf -> scgi_lengths ))
1229- {
1229+ if (slcf -> upstream .upstream || slcf -> scgi_lengths ) {
12301230 conf -> conf = & conf -> scgi ;
1231- conf -> handler = ngx_http_scgi_cache_purge_handler ;
1231+ conf -> handler = slcf -> upstream .cache
1232+ ? ngx_http_scgi_cache_purge_handler : NULL ;
12321233 conf -> original_handler = clcf -> handler ;
1233-
12341234 clcf -> handler = ngx_http_cache_purge_access_handler ;
12351235
12361236 return NGX_CONF_OK ;
@@ -1244,11 +1244,10 @@ ngx_http_cache_purge_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
12441244 if (conf -> uwsgi .enable && clcf -> handler != NULL ) {
12451245 ulcf = ngx_http_conf_get_module_loc_conf (cf , ngx_http_uwsgi_module );
12461246
1247- if (ulcf -> upstream .cache
1248- && (ulcf -> upstream .upstream || ulcf -> uwsgi_lengths ))
1249- {
1247+ if (ulcf -> upstream .upstream || ulcf -> uwsgi_lengths ) {
12501248 conf -> conf = & conf -> uwsgi ;
1251- conf -> handler = ngx_http_uwsgi_cache_purge_handler ;
1249+ conf -> handler = ulcf -> upstream .cache
1250+ ? ngx_http_uwsgi_cache_purge_handler : NULL ;
12521251 conf -> original_handler = clcf -> handler ;
12531252
12541253 clcf -> handler = ngx_http_cache_purge_access_handler ;
0 commit comments