如何在不通过健康检查的情况下在亚马逊弹性豆茎上强制使用 https [英] How to force https on amazon elastic beanstalk without failing the health check
问题描述
我已经将我的 Elastic Beanstalk 环境配置为将所有页面重定向到 https,重定向工作,但是,实例未通过健康检查并被终止,任何想法如何配置重写规则?
I have configured my Elastic Beanstalk environment to redirect all pages to https, redirection works, however, the instance fails the health check and gets terminated, any ideas how to configure the rewrite rules?
我的配置:
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
的请求.
There's multiple hostmananger URLs that Elastic Beanstalk needs to access besides the health check. Grepping /var/log/httpd/elasticbeanstalk-access_log
, I see requests to /_hostmanager/tasks
and /_hostmanager/healthcheck
.
以下是我在 EC2 实例上添加到 /etc/httpd/sites/elasticbeanstalk
的规则:
Here are the rules that I added to /etc/httpd/sites/elasticbeanstalk
on my EC2 instances:
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,因此跳过重写的流量将避免重定向并使状态查找更快(我假设).
Note that I'm also allowing non-https traffic to my /status
and /version
pages. I'm actually using /status
as the actual healthcheck lookup URL, so having that traffic skip the rewrite will avoid the redirect and make the status lookup faster (I'm assuming).
这篇关于如何在不通过健康检查的情况下在亚马逊弹性豆茎上强制使用 https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!