AWS Elastic Load Balancer HTTP 健康检查 ping 未到达 Rails 应用程序服务器

AWS Elastic Load Balancer HTTP 健康检查 ping 未到达 Rails 应用程序服务器

我刚刚继承了一个在 AWS Elastic Beanstalk 上运行的 Ruby + Rails 应用程序,它目前使用 TCP 进行 Elastic Load Balancer 健康检查。我希望切换到 HTTP,并真正访问我的应用程序。

为此,我在应用程序上创建了一个始终返回状态 200 的端点。我部署了它,并使用 curl 对其进行了测试。

louis $ curl -I https://my.domain.goes.here/__status__
HTTP/1.1 200 OK
Cache-Control: max-age=0, private, must-revalidate
Date: Tue, 25 Aug 2015 16:09:29 GMT
ETag: W/"028714d01e3aa7ed0ffa7a023f82ca94"
Server: nginx/1.6.2
Strict-Transport-Security: max-age=31536000
X-Request-Id: 1ce6b907-779a-45d2-b9f9-d19a74ef8abd
X-Runtime: 0.002703
Connection: keep-alive

这是我所期望的结果。

我使用 AWS 控制台来设置健康检查,其配置如下:

Ping Target          HTTP:80/__status__
Timeout              5 seconds
Interval             30 seconds
Unhealthy Threshold  5
Healthy Threshold    3

但现在健康检查总是失败。443 端口上的 HTTPS 也一样

我 ssh 进入实例并从那里 curl。

# With the "Private IP"
[ec2-user@ip-$PRIVATE_IP_ADDRESS ~]$ curl -I $PRIVATE_IP_ADDRESS/__status__
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.2
Date: Wed, 26 Aug 2015 08:14:21 GMT
Content-Type: text/html
Connection: keep-alive
Location: https://$PRIVATE_IP_ADDRESS/__status__

# With the "Private DNS"
[ec2-user@ip-$PRIVATE_IP_ADDRESS ~]$ curl -I $PRIVATE_DNS_ADDRESS/__status__
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.2
Date: Wed, 26 Aug 2015 08:17:20 GMT
Content-Type: text/html
Connection: keep-alive
Location: https://$PRIVATE_DNS_ADDRESS/__status__

# With the "Public IP"
[ec2-user@ip-$PRIVATE_IP_ADDRESS ~]$ curl -I $PUBLIC_IP_ADDRESS/__status__
curl: (7) Failed to connect to $PUBLIC_IP_ADDRESS port 80: Connection timed out

# With the "Public DNS"
[ec2-user@ip-$PRIVATE_IP_ADDRESS ~]$ curl -I $PUBLIC_DNS_ADDRESS/__status__
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.2
Date: Wed, 26 Aug 2015 07:24:37 GMT
Content-Type: text/html
Connection: keep-alive
Location: https://$PUBLIC_DNS_ADDRESS/__status__

# With the "Public DNS" over HTTPS
[ec2-user@ip-$PRIVATE_IP_ADDRESS ~]$ curl -I https://$PUBLIC_DNS_ADDRESS/__status__
curl: (7) Failed to connect to $PUBLIC_DNS_ADDRESS port 443: Connection refused

这可能是什么问题?

答案1

ELB 不会访问您的域名,而是访问您的 IP 地址。测试curl -I https://my.**IP**.goes.here/__status__以验证您的状态检查是否正常工作 - 它将访问默认虚拟主机。

编辑:根据更新后的结果,您的服务器正在将您的 HTTP 访问重定向到 HTTPS。ELB 不认为 301 是成功,因此将其视为失败。将您的状态页面从 HTTP → HTTPS 重定向中豁免。

相关内容