laravel - 在Docker之后运行的Nginx上的随机502/503错误(在ECS群集+ ALB上)

标签 laravel amazon-web-services docker nginx amazon-ecs

因此,我已经设置了一个laravel应用程序,并托管在一个 docker 中,该 docker 使用运行在ALB之后的AWS ECS Cluster托管。

到目前为止,我已经按照预期的方式启动并运行了应用程序,一切都按其原样运行(例如, session 存储在内存缓存中并且可以正常工作,静态 Assets 位于S3存储桶中,等等)。

现在,我只遇到1个稳定性问题,而且我不确定自己到底在哪里。当我访问我的URL /网站时,有时(随机)返回502/503 HTTP错误。发生这种情况时,我必须等待一分钟或2分钟,然后该应用才能返回200个HTTP代码。

这是在docker上执行拖尾操作的结果(即nginx日志)

enter image description here

在这一点上,我完全迷路了,不确定我还应该去哪里检查。我尝试了以下方法:

  • 使用相同的docker / nginx >>在本地运行它就可以了。
  • 在没有ALB的情况下运行(即仅使用1个EC2)>>有类似问题。
  • 使用ALB在2种不同的EC2类型(即t2.small和micro)上运行,它们都具有类似的问题。
  • 仅在具有类似问题的EC2 >>上使用ALB运行它。
  • 最佳答案

    根据您的日志,ngjnx对ALB健康检查请求的答复为401未经授权。您必须在/终结点中回答200 OK,或者在ALB目标组中配置另一种类似/ping的值。
    使用控制台检查目标的运行状况

    1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

    2. On the navigation pane, under LOAD BALANCING, choose Target Groups.

    3. Select the target group.

    4. On the Targets tab, the Status column indicates the status of each target.

    5. If the status is any value other than Healthy, view the tooltip for more information.


    更多信息:https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html

    关于laravel - 在Docker之后运行的Nginx上的随机502/503错误(在ECS群集+ ALB上),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53389265/

    相关文章:

    laravel - 我做了订单管理系统,如何在laravel中合计价格?

    amazon-web-services - 如何解决 AWS Bad String 上的 JSON 错误?

    amazon-web-services - 如何处理对 Amazon Lex 的 lambda 响应?

    amazon-web-services - 如何在cloudformation中自引用SourceSecurityGroup?

    docker - 通过终端获取 Docker for mac 代理变量

    docker - 使用docker使用AWS命令

    docker - Vagrant up --no-parallel 标志含义

    php - laravel 中 ajax 调用时如何传递所需的查询

    laravel - 使用作者姓名存储数据 - laravel 5.2

    php - SQL Server随机超时问题