我在 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 服务都已启动并运行
我还可以 curl 以下内容(使用本地主机和主机名通过,但使用 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 只在本地主机上监听,你可以检查一下
$ ss -l -t | grep http
这将列出所有进程正在监听的以 http 命名的所有 TCP 端口。
它应该显示如下内容:
LISTEN 0 128 *:http-alt *:*
LISTEN 0 128 *:http *:*
如果 :http
前面没有 *
而是 127.0.0.1
而是你的问题,你应该检查你的nginx 配置在 listen
选项之后,将其更改为 *:80
,如果找不到,请添加它。
关于tomcat - 使用 Nginx/Tomcat 时 EC2/ELB 健康检查失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46903361/