【发布时间】:2019-04-16 15:52:03
【问题描述】:
我在 Apache 服务器上使用 AWS Elastic Beanstalk 部署了一个 node.js 环境。我在环境中运行了 PCI 扫描,但出现 2 次失败:
- Apache ServerTokens 信息披露
- Web 服务器 HTTP 标头信息披露
当然,我认为我需要使用以下内容更新 httpd.conf 文件:
ServerSignature Off
ServerTokens Prod
但是,鉴于 Elastic Beanstalk 和 Elastic Load Balancer 的性质,一旦环境扩展、添加新服务器、重启等,实例配置就会被覆盖。
我还尝试将以下内容放入 .htaccess 文件中:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]
# Security hardening for PCI
Options -Indexes
ServerSignature Off
# Dissallow iFrame usage outside of loylap.com for PCI Security Scan
Header set X-Frame-Options SAMEORIGIN
在 node js 端,我使用“helmet”包来应用一些安全措施,我还使用“express-force-https”包来确保应用程序强制执行 https。但是,这些似乎只有在 Express 应用程序启动和重定向之后才会生效。
我为 HTTP(端口 80)和 HTTPS(端口 443)设置了 Elastic Load Balancer 侦听器,但是 HTTP 请求会立即路由到 HTTPS。
当我运行以下 curl 命令时:
curl -I https://myenvironment.com --head
我得到了可以接受的回复:
Server: Apache
但是,当我在 http 端点上运行相同的请求时(即在重定向之前等):
curl -I http://myenvironment.com --head
我收到一条回复,其中披露了有关我的服务器的更多信息,因此 PCI 失败:
Server: Apache/2.4.34 (Amazon)
如何强制我的环境限制 HTTP 和 HTTPS 上的 http 标头响应?
【问题讨论】:
标签: apache amazon-web-services amazon-elastic-beanstalk