File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 66#include <ngx_config.h>
77#include <ngx_core.h>
88#include <ngx_http.h>
9+ #include <ngx_string.h>
910
1011#define NGX_HTTP_SECURITY_HEADER_OMIT 0
1112
@@ -203,6 +204,10 @@ ngx_http_security_headers_filter(ngx_http_request_t *r)
203204 ngx_str_t key ;
204205 ngx_str_t val ;
205206
207+ ngx_str_t scheme = ngx_string ("scheme" );
208+ ngx_uint_t scheme_hash_key = ngx_hash_key (scheme .data , scheme .len );
209+ ngx_http_variable_value_t * scheme_value ;
210+
206211 slcf = ngx_http_get_module_loc_conf (r , ngx_http_security_headers_module );
207212
208213 if (1 == slcf -> hide_server_tokens ) {
@@ -268,7 +273,8 @@ ngx_http_security_headers_filter(ngx_http_request_t *r)
268273 ngx_set_headers_out_by_search (r , & key , & val );
269274 }
270275
271- if (r -> schema .len == 5 && ngx_strncmp (r -> schema .data , "https" , 5 ) == 0 )
276+ scheme_value = ngx_http_get_variable (r , & scheme , scheme_hash_key );
277+ if (scheme_value && !scheme_value -> not_found && scheme_value -> len == 5 && ngx_strncmp (scheme_value -> data , "https" , 5 ) == 0 )
272278 {
273279 ngx_str_set (& key , "Strict-Transport-Security" );
274280 if (1 == slcf -> hsts_preload ) {
You can’t perform that action at this time.
0 commit comments