简体   繁体   中英

How to remove server header from nginx response in elastic beanstalk

I am trying to remove the server header ( server: nginx/1.20.0 ) from elastic beanstalk response. I have added 00_server.conf to .platform/nginx/conf.d/ in the source bundle with the following configuration

server {
    server_tokens off;
}

I am expecting this would extend the Elastic Beanstalk default nginx configuration as mentioned here and at least remove the version from the server header. But this is not working.

I need help with the following things:

  1. How do I extend the default configuration so that I can remove the server version?
  2. How do I remove the complete header?

I have looked at the similar questions on stackoverflow but they don't seem to help.

Update : Issue 1 is resolved. server_tokens need to be inside the http context. Updating the above configuration to

server_tokens off;

fixed the problem.

To remove the Server header completely you have many options , of which most prominent would be using ngx_security_headers module:

hide_server_tokens on;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM