【问题标题】:How to hide the NGINX "server" response header (e.g nginx/1.12.2) in Amazon Linux 2 (AMI)?如何在 Amazon Linux 2 (AMI) 中隐藏 NGINX“服务器”响应标头(例如 nginx/1.12.2)?
【发布时间】:2021-06-04 09:49:18
【问题描述】:

ASAIK,我们需要安装 3rd 方模块(例如 more_clear_headers)并在 nginx.conf 中添加配置以完全删除服务器头。

load_module modules/ngx_http_headers_more_filter_module.so;

http {
    ...
    more_clear_headers Server;
    ...
}

但是,在 AMI 中,如何做到这一点?

使用此命令没有包: $ yum install more_clear_headers

【问题讨论】:

    标签: nginx amazon-linux


    【解决方案1】:

    只有商业解决方案可以从包中安装。您可以使用 NGINX Plus(价格昂贵)或支持 Amazon Linux 2 的更便宜的 GetPageSpeed 存储库。

    通过 the article 从 GetPageSpeed repo 设置模块:

    sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
    sudo yum -y install nginx-module-headers-more
    

    现在您可以像这样调整您的nginx.conf

    load_module modules/ngx_http_headers_more_filter_module.so;
    
    http {
        ...
        more_clear_headers Server;
        ...
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-24
      • 1970-01-01
      • 2021-01-10
      • 2014-08-27
      • 2021-12-03
      • 1970-01-01
      • 2014-01-09
      • 1970-01-01
      相关资源
      最近更新 更多