Skip to content

Commit

Permalink
Filtering the webserver information in the nginx default error responses
Browse files Browse the repository at this point in the history
Signed-off-by: jan shahid shaik <jashaik@progress.com>
  • Loading branch information
jashaik committed Jun 17, 2021
1 parent e428331 commit 8f25de0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ http {
# logged to the request log.
log_not_found off;

error_page 301 400 401 402 403 405 406 407 408 409 410 411 412 413 414 415 416 417
418 421 422 423 424 425 426 428 429 431 451 500 501 502 504 505 506 507 508 510 511 = @errorrespfilter;
server_names_hash_bucket_size <%= @server_names_hash_bucket_size %>;

sendfile <%= @sendfile %>;
Expand Down Expand Up @@ -148,6 +150,13 @@ http {
more_clear_headers Server;
access_log /var/log/opscode/nginx/rewrite-port-80.log;
return 301 https://$host$request_uri;
location @errorrespfilter {
return 301 https://$host$request_uri;
header_filter_by_lua_block { ngx.header.content_length = nil }
body_filter_by_lua '
ngx.arg[1] = ngx.re.sub(ngx.arg[1],"openresty", "chef")
';
}
}
<%- end -%>
<%- end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@

error_page 404 =404 /404.html;
error_page 503 =503 /503.json;
error_page 400 401 402 403 405 406 407 408 409 410 411 412 413 414 415 416 417
418 421 422 423 424 425 426 428 429 431 451 500 501 502 504 505 506 507 508 510 511 = @errorrespfilter;

# Whitelist the docs necessary to serve up error pages and friendly
# html to non-chef clients hitting this host.
Expand Down Expand Up @@ -209,4 +211,10 @@
proxy_pass http://$upstream;
proxy_redirect http://$upstream /;
}
location @errorrespfilter {
header_filter_by_lua_block { ngx.header.content_length = nil }
body_filter_by_lua '
ngx.arg[1] = ngx.re.sub(ngx.arg[1],"openresty", "chef")
';
}
}

0 comments on commit 8f25de0

Please sign in to comment.