nginxnginx-reverse-proxynginx-confignginx-location

Clearing All Response Headers in NGINX


I understand that I can use one of the following to remove specific headers from the response in NGINX

proxy_hide_header
more_clear_headers

proxy_hide_header

more_clear_headers

However, As I mentioned, my requirement is to remove all of the response headers. Above directives will only help in removing specified headers. Is there any way I can remove all headers before sending the response?


Solution

  • more_clear_headers supports wildcard *

    so this works for all X-Headers: more_clear_headers 'X-*';

    While more_clear_headers '*'; does not work, thanks to user582175. So you have to clean specificly the headers you don't want to have.

    But you have to build from source for using headers-more-nginx-modul.