【问题标题】:EC2/ELB Health Check Fails with Nginx/Tomcat使用 Nginx/Tomcat 的 EC2/ELB 运行状况检查失败
【发布时间】:2018-04-04 19:52:29
【问题描述】:

我在 ELB 后面有一个 Ec2/RHEL7。 EC2有Nginx监听80端口,Tomcat监听8080端口。ELB Healthcheck如下

Ping Target 
HTTP:80/index.html
Timeout 5 seconds
Interval    30 seconds
Unhealthy threshold 10
Healthy threshold   3

ELB 健康检查不断失败,ec2 停止服务

我已经更新了 ngix conf(在 site-available 和 sites-enabled 下) Nginx 和 tomcat 服务都已启动并运行

我还可以卷曲以下内容(使用 localhost 和主机名通过,但使用 IP 地址失败)

[ec2-user@ip-10-190-180-30 ~]$ curl -I  localhost:80/index.html
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 24 Oct 2017 06:05:25 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Location: https://localhost/index.html
Strict-Transport-Security: "max-age=31536000; includeSubdomains;"
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: "1; mode=block"

curl -I  10.160.xx.xx:80/index.html
HTTP/1.1 503 Service Unavailable
Server: squid/3.5.20
Mime-Version: 1.0
Date: Tue, 24 Oct 2017 06:07:50 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 3659
X-Squid-Error: ERR_CONNECT_FAIL 110
X-Cache: MISS from izss-proxy-a2
X-Cache-Lookup: MISS from izss-proxy-a2:3128
Via: 1.1 izss-proxy-a2 (squid/3.5.20)
Connection: keep-alive

ELB 运行状况检查失败。不知道我错过了什么。

【问题讨论】:

  • 发布你的 nginx 配置

标签: tomcat nginx amazon-ec2 amazon-elb


【解决方案1】:

听起来 nginx 只在 localhost 上监听,你可以检查一下

$ ss -l -t | grep http

这将列出任何进程正在侦听的所有以 http 命名的 TCP 端口。

它应该显示如下内容:

LISTEN     0      128        *:http-alt                 *:*                    
LISTEN     0      128        *:http                     *:*

如果:http 前面没有*127.0.0.1 是您的问题,您应该在listen 选项之后检查您的nginx 配置并将其更改为*:80,如果您找不到就加吧。

【讨论】:

  • 输出看起来不错,但健康检查仍然失败 ss -l -t | grep http LISTEN 0 128 :http *: LISTEN 0 128 :https *:
【解决方案2】:

检查您的 ec2 安全组并确保 ELB 可以访问端口 80。

最佳做法是采用 ELB 安全组并在 ec2 安全组上创建入站规则,以允许 ELB 安全组访问 ec2 上的端口 80。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-05
    • 1970-01-01
    • 2020-02-19
    • 2021-12-26
    • 2022-01-19
    • 2015-01-12
    • 1970-01-01
    相关资源
    最近更新 更多