简体   繁体   English

如何从 static 内容中删除 Elastic Beanstalk Apache 服务器 header?

[英]How can I remove Elastic Beanstalk Apache server header from static content?

I have an Elastic Beanstalk AML 2 setup, running an Apache proxy server.我有一个 Elastic Beanstalk AML 2 设置,运行一个 Apache 代理服务器。

I have successfully minimised the server header from GET request to / by extending the httpd.conf via the following file通过以下文件扩展 httpd.conf,我已经成功地将服务器 header 从 GET 请求最小化到 /

.platform/httpd/conf.d/httpd.conf .platform/httpd/conf.d/httpd.conf

the contents are:内容是:

ServerSignature Off
ServerTokens Prod

This works for the page request, and only reports 'Apache' as my server token/signature.这适用于页面请求,并且仅将“Apache”报告为我的服务器令牌/签名。

But requests for static content (such as images, css, js) still report the full signature.但是请求static内容(比如图片,css,js)还是报完整签名。

How can I apply the same to static content?我如何将相同的内容应用于 static 内容?

In a standard AWS beanstalk environment with Apache httpd configured, all web content (static and dynamic) will be served through httpd (httpd acts as a proxy for requests sent to tomcat or other dynamic web content).在配置了 Apache httpd 的标准 AWS beanstalk 环境中,所有 web 内容(静态和动态)都将通过 httpd 提供(httpd 充当发送到 tomcat 或其他动态 web 内容的请求的代理)。

And as ServerSignature and ServerTokens are global configuration settings, if this setting change works for some pages, it should work for all static content too.由于 ServerSignature 和 ServerTokens 是全局配置设置,如果此设置更改适用于某些页面,它也应该适用于所有 static 内容。

I experienced a similar issue to you after applying the same Apache settings, but this was because the browser was serving static content from its own cache (and the server header shown was from the original request before I changed Apache).在应用相同的 Apache 设置后,我遇到了与您类似的问题,但这是因为浏览器从其自己的缓存中提供 static 内容(显示的server header 来自我更改 Apache 之前的原始请求)。 I fixed this by doing a hard reload / flush cache on my browser.我通过在浏览器上执行硬重新加载/刷新缓存来解决此问题。

You can verify httpd is working, by connecting to your EC2 server via ssh and running您可以通过 ssh 连接到您的 EC2 服务器并运行来验证 httpd 是否正常工作

# Check page (update to the dynamic page you want to test)
curl -I localhost/path/mypage
# Check image/css (update path to the static resource you want to test)
curl -I localhost/img/test.png

# In Apache/Tomcat, you can view the Tomcat page directly
# (but note that your browser will not see this directly, it will be proxied via httpd)
curl -I localhost:8080/path/mypage

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

相关问题 如何从弹性 beantalk 中的 nginx 响应中删除服务器 header - How to remove server header from nginx response in elastic beanstalk 如何在 Elastic Beanstalk 上添加 PATH - How can I add PATH on Elastic Beanstalk Elastic Beanstalk - 从标头中删除 Nginx 版本 - Elastic Beanstalk - Remove Nginx version from headers 如何在要部署到 AWS 弹性豆茎中的 Flask 应用程序中使用我的 firebase 凭证? - How can I use my firebase credentials in a Flask application that I want to deploy in a AWS elastic beanstalk? 如何在 Elastic Beanstalk 中安排每晚重启应用程序服务器 - How to schedule nightly restart of application server in Elastic Beanstalk 我可以使用 AWS Elastic Beanstalk 托管 Spring Boot 应用程序吗 - Can I use AWS Elastic Beanstalk to host a Spring Boot application Elastic Beanstalk 节点 Static 文件未加载 - Elastic Beanstalk Node Static Files are not Loaded Amazon Elastic Beanstalk 不提供 django static 个文件 - Amazon Elastic Beanstalk not serving django static files 如何在 terraform 中将 rds 与弹性 beantalk 连接 - How do I connect rds with elastic beanstalk in terraform 我将如何为 Terraform 上的 AWS Elastic Beanstalk 定义 URL/域? - How would I define the URL/Domain for AWS Elastic Beanstalk on Terraform?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM