【问题标题】:LoadBalancer in EC2 Instance showing status OutOfServiceEC2 实例中的 LoadBalancer 显示状态 OutOfService
【发布时间】:2020-01-25 17:11:01
【问题描述】:

这是我的场景。

我正在使用 ACM 生成 2 个 SSL 证书。 example.com*.example.com

我有 2 个负载均衡器链接到同一个 EC2 实例。

1) 链接到我的 wordpress 网站 - example.com

2) 链接到我的应用 - *.example.com

我为排除服务中断错误而遵循的清单:

1) 实例状态 - 运行中

2) 状态检查 - 2/2

3) 安全组设置 - 端口 80/443/22 开放

4) 以下是我的健康检查设置

Ping 目标 - HTTP:80/ 超时 - 5 秒 间隔 - 30 秒 不健康阈值 - 2 健康阈值 - 10

我正在使用 NGINX 网络服务器。我检查了状态,它显示它处于活动状态。

这是我的配置文件example.com

server
{
  server_name www. example.com;
  return 301 $scheme://example.com$request_uri;
}


server {

 listen       80;
 listen       443;

 server_name example.com;

 root /opt/bitnami/apps/wordpress/htdocs; 


}


server {

 listen       80;
 listen       443;

 server_name ~^(.*)\. example\.com$ ;

 root /opt/bitnami/apps/example_app;


}

这可能是什么问题?问题与 NGINX 配置设置有关还是与负载均衡器设置有关?

【问题讨论】:

  • 如果你在实例中运行 curl 你会得到预期的 html 内容吗? (适用于您的 wordpress 和应用网站)

标签: amazon-web-services amazon-ec2 load-balancing


【解决方案1】:

您的 nginx 设置肯定不正确。实例级别没有 SSL。相反,elb 将终止与客户端的 SSL 连接。 ec2 实例应该接受的唯一连接是在端口 80 上,并且只能来自 elb。我建议你删除 nginx 中三个引用的 SSL 报告,并确保它的配置如上。

【讨论】:

  • 我删除了listen 443; 并尝试了。得到同样的错误。奇怪的是类似的配置(如我的问题中提到的)在另一个网络应用程序中运行良好。
  • 其他应用是在php上运行的吗?
  • @MichaelQuale 是的
【解决方案2】:

你肯定需要配置 nginx 来运行 php 脚本。由于 php 是一个预处理引擎,你的 nginx 配置需要知道如何处理 php 文件。

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name server_domain_or_IP;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

参考:https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-in-ubuntu-16-04

由于您提到这是一个 wordpress 网站,因此您需要设置一个 LEMP 堆栈。

【讨论】:

    猜你喜欢
    • 2019-02-17
    • 2014-05-05
    • 1970-01-01
    • 1970-01-01
    • 2021-11-03
    • 1970-01-01
    • 2018-05-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多