@@ -46,6 +46,12 @@ char *ngx_http_proxy_cache_purge_conf(ngx_conf_t *cf,
4646ngx_int_t ngx_http_proxy_cache_purge_handler (ngx_http_request_t * r );
4747# endif /* NGX_HTTP_PROXY */
4848
49+ # if (NGX_HTTP_SCGI )
50+ char * ngx_http_scgi_cache_purge_conf (ngx_conf_t * cf ,
51+ ngx_command_t * cmd , void * conf );
52+ ngx_int_t ngx_http_scgi_cache_purge_handler (ngx_http_request_t * r );
53+ # endif /* NGX_HTTP_SCGI */
54+
4955# if (NGX_HTTP_UWSGI )
5056char * ngx_http_uwsgi_cache_purge_conf (ngx_conf_t * cf ,
5157 ngx_command_t * cmd , void * conf );
@@ -78,6 +84,15 @@ static ngx_command_t ngx_http_cache_purge_module_commands[] = {
7884 NULL },
7985# endif /* NGX_HTTP_PROXY */
8086
87+ # if (NGX_HTTP_SCGI )
88+ { ngx_string ("scgi_cache_purge" ),
89+ NGX_HTTP_LOC_CONF |NGX_CONF_TAKE2 ,
90+ ngx_http_scgi_cache_purge_conf ,
91+ NGX_HTTP_LOC_CONF_OFFSET ,
92+ 0 ,
93+ NULL },
94+ # endif /* NGX_HTTP_SCGI */
95+
8196# if (NGX_HTTP_UWSGI )
8297 { ngx_string ("uwsgi_cache_purge" ),
8398 NGX_HTTP_LOC_CONF |NGX_CONF_TAKE2 ,
@@ -349,6 +364,95 @@ ngx_http_proxy_cache_purge_handler(ngx_http_request_t *r)
349364}
350365# endif /* NGX_HTTP_PROXY */
351366
367+ # if (NGX_HTTP_SCGI )
368+ extern ngx_module_t ngx_http_scgi_module ;
369+
370+ typedef struct {
371+ ngx_http_upstream_conf_t upstream ;
372+
373+ ngx_array_t * flushes ;
374+ ngx_array_t * params_len ;
375+ ngx_array_t * params ;
376+ ngx_array_t * params_source ;
377+
378+ ngx_hash_t headers_hash ;
379+ ngx_uint_t header_params ;
380+
381+ ngx_array_t * scgi_lengths ;
382+ ngx_array_t * scgi_values ;
383+
384+ ngx_http_complex_value_t cache_key ;
385+ } ngx_http_scgi_loc_conf_t ;
386+
387+ char *
388+ ngx_http_scgi_cache_purge_conf (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
389+ {
390+ ngx_http_compile_complex_value_t ccv ;
391+ ngx_http_core_loc_conf_t * clcf ;
392+ ngx_http_scgi_loc_conf_t * slcf ;
393+ ngx_str_t * value ;
394+
395+ slcf = ngx_http_conf_get_module_loc_conf (cf , ngx_http_scgi_module );
396+
397+ /* check for duplicates / collisions */
398+ if (slcf -> upstream .cache != NGX_CONF_UNSET_PTR
399+ && slcf -> upstream .cache != NULL )
400+ {
401+ return "is either duplicate or collides with \"scgi_cache\"" ;
402+ }
403+
404+ if (slcf -> upstream .upstream || slcf -> scgi_lengths ) {
405+ return "is incompatible with \"scgi_pass\"" ;
406+ }
407+
408+ if (slcf -> upstream .store > 0 || slcf -> upstream .store_lengths ) {
409+ return "is incompatible with \"scgi_store\"" ;
410+ }
411+
412+ value = cf -> args -> elts ;
413+
414+ /* set scgi_cache part */
415+ slcf -> upstream .cache = ngx_shared_memory_add (cf , & value [1 ], 0 ,
416+ & ngx_http_scgi_module );
417+ if (slcf -> upstream .cache == NULL ) {
418+ return NGX_CONF_ERROR ;
419+ }
420+
421+ /* set scgi_cache_key part */
422+ ngx_memzero (& ccv , sizeof (ngx_http_compile_complex_value_t ));
423+
424+ ccv .cf = cf ;
425+ ccv .value = & value [2 ];
426+ ccv .complex_value = & slcf -> cache_key ;
427+
428+ if (ngx_http_compile_complex_value (& ccv ) != NGX_OK ) {
429+ return NGX_CONF_ERROR ;
430+ }
431+
432+ /* set handler */
433+ clcf = ngx_http_conf_get_module_loc_conf (cf , ngx_http_core_module );
434+
435+ clcf -> handler = ngx_http_scgi_cache_purge_handler ;
436+
437+ return NGX_CONF_OK ;
438+ }
439+
440+ ngx_int_t
441+ ngx_http_scgi_cache_purge_handler (ngx_http_request_t * r )
442+ {
443+ ngx_http_scgi_loc_conf_t * slcf ;
444+
445+ if (!(r -> method & (NGX_HTTP_GET |NGX_HTTP_HEAD |NGX_HTTP_DELETE ))) {
446+ return NGX_HTTP_NOT_ALLOWED ;
447+ }
448+
449+ slcf = ngx_http_get_module_loc_conf (r , ngx_http_scgi_module );
450+
451+ return ngx_http_cache_purge_handler (r , slcf -> upstream .cache -> data ,
452+ & slcf -> cache_key );
453+ }
454+ # endif /* NGX_HTTP_SCGI */
455+
352456# if (NGX_HTTP_UWSGI )
353457extern ngx_module_t ngx_http_uwsgi_module ;
354458
0 commit comments