apache - 如何在不通过健康检查的情况下在亚马逊 Elastic Beanstalk 上强制使用 https

标签 apache amazon-web-services mod-rewrite https amazon-elastic-beanstalk

这个问题在这里已经有了答案:





How to force https on elastic beanstalk?

(22 个回答)


3年前关闭。




我已将 Elastic Beanstalk 环境配置为将所有页面重定向到 https,重定向有效,但是,实例未通过运行状况检查并被终止,您知道如何配置重写规则吗?

我的配置:

NameVirtualHost *:80

<VirtualHost *:80>
.
.
.

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule !/_hostmanager/healthcheck https://%{SERVER_NAME}%{REQUEST_URI} [L,R] 
</VirtualHost>

最佳答案

除了运行状况检查之外,Elastic Beanstalk 还需要访问多个 hostmananger URL。 Grepping /var/log/httpd/elasticbeanstalk-access_log , 我看到对 /_hostmanager/tasks 的请求和 /_hostmanager/healthcheck .

这是我添加到 /etc/httpd/sites/elasticbeanstalk 的规则在我的 EC2 实例上:

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} !^/status$ 
RewriteCond %{REQUEST_URI} !^/version$ 
RewriteCond %{REQUEST_URI} !^/_hostmanager/ 
RewriteRule . https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

请注意,我还允许非 https 流量进入我的 /status/version页。我实际上在使用 /status作为实际的健康检查查找 URL,因此让流量跳过重写将避免重定向并使状态查找更快(我假设)。

关于apache - 如何在不通过健康检查的情况下在亚马逊 Elastic Beanstalk 上强制使用 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6858492/

相关文章:

php - 重写 URL 以删除扩展名 .htaccess 时出现内部服务器错误

.htaccess - RewriteRule接受2个参数

mod-rewrite - IIS URL 重写 : Redirect not working?

apache - .htaccess 即使启用了 allowoverride 也无法正常工作

macos - Apache 无法在 OSX 中的 MAMP 中启动(但 MySQL 可以工作)

amazon-web-services - AWS Transfer 系列中从不要求 AWS Lambda 进行身份验证

amazon-web-services - CloudFormation SecurityGroup 循环引用

amazon-web-services - 为什么我在 Terraform 中尝试 auto_accept vpc 对等互连时收到权限错误?

python - mod_wsgi、mod_python,还是只是 cgi?

php - 白屏后没有记录 PHP/Smarty 错误