简体   繁体   English

Elastic Beanstalk - 从标头中删除 Nginx 版本

[英]Elastic Beanstalk - Remove Nginx version from headers

I am using Elastic Beanstalk for hosting my node app.我正在使用 Elastic Beanstalk 来托管我的节点应用程序。 In my node response I got a header that shows the Nginx version.在我的节点响应中,我得到了一个 header,它显示了Nginx版本。 For security reasons I want to remove or overwrite it.出于安全原因,我想删除或覆盖它。

I don't want to change anything else.我不想改变任何其他东西。 I just want to remove this header only.我只想删除这个 header。

I also tried to send header from backend side but Nginx overwrites this header.我还尝试从后端发送 header,但Nginx覆盖了这个 header。

响应图像

You will need to configure the nginx to turn server headers off.您将需要配置 nginx 以关闭服务器标头。 The way to configure the nginx.conf file for Elastic Beanstalk is described here - https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-nginx.html此处描述了为 Elastic Beanstalk 配置nginx.conf文件的方法 - https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-nginx.html

And you need to set server_tokens off;并且您需要server_tokens off; in the nginx configuration.在 nginx 配置中。 Detail of this config can be found at http://nginx.org/en/docs/http/ngx_http_core_module.html#server_tokens此配置的详细信息可在http://nginx.org/en/docs/http/ngx_http_core_module.html#server_tokens找到

Syntax: server_tokens on |语法:server_tokens on | off |关闭 | build |建造 | string;细绳; Default:默认:

server_tokens on; server_tokens 开启;

Context: http, server, location上下文:http,服务器,位置

Enables or disables emitting nginx version on error pages and in the “Server” response header field.启用或禁用在错误页面和“服务器”响应 header 字段中发出 nginx 版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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