AWS ALB 路由 - 未找到请求的 url

AWS ALB routing - Requested url not found

我有一个微服务专门用作网站管理区域的前端。微服务有一条专用于它的路由,/admin。当我尝试访问时,它给了我一个 404 error。下面给出的是微服务云模板的摘录。

Resources:
  Service:
    Type: AWS::ECS::Service
    DependsOn: ListenerRule
    Properties:
      Cluster: !Ref Cluster
      Role: !Ref ServiceRole
      DesiredCount: !Ref DesiredCount
      TaskDefinition: !Ref TaskDefinition
      LoadBalancers:
        - ContainerName: "activity-monitor-service"
          ContainerPort: 80
          TargetGroupArn: !Ref TargetGroup

  TaskDefinition:
    Type: AWS::ECS::TaskDefinition
    Properties:
      Family: activity-monitor-service
      ContainerDefinitions:
        - Name: activity-monitor-service
          Essential: true
          Image: registry.hub.docker.com/abameerdeen/activity_monitor:v4
          Memory: 128
          Environment:
            - Name: PRODUCT_SERVICE_URL
              Value: !Ref ProductServiceUrl
          PortMappings:
            - ContainerPort: 80
          LogConfiguration:
            LogDriver: awslogs
            Options:
              awslogs-group: !Ref CloudWatchLogsGroup
              awslogs-region: !Ref AWS::Region

  CloudWatchLogsGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: !Ref AWS::StackName
      RetentionInDays: 365

  TargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      VpcId: !Ref VPC
      Port: 80
      Protocol: HTTP
      Matcher:
        HttpCode: 200-299
      HealthCheckIntervalSeconds: 10
      HealthCheckPath: /test.html
      HealthCheckProtocol: HTTP
      HealthCheckTimeoutSeconds: 5
      HealthyThresholdCount: 2

  ListenerRule:
    Type: AWS::ElasticLoadBalancingV2::ListenerRule
    Properties:
      ListenerArn: !Ref Listener
      Priority: 2
      Conditions:
        - Field: path-pattern
          Values: [ "/admin/*" ]
      Actions:
        - TargetGroupArn: !Ref TargetGroup
          Type: forward

我在基础架构中也有一个应用程序负载均衡器 (ALB)。这是我的项目:https://github.com/ammarisme/aws-cloudformation.git

上面 ListenerRule 匹配管理文件夹中的文件(例如:- index.html)而不是路径 /。因此,我添加了缺少的 ListenerRule,如下所示。

ListenerRule2:
    Type: AWS::ElasticLoadBalancingV2::ListenerRule
    Properties:
      ListenerArn: !Ref Listener
      Priority: 3
      Conditions:
        - Field: path-pattern
          Values: [ "/admin" ]
      Actions:
        - TargetGroupArn: !Ref TargetGroup
          Type: forward