fabiolb / fabio

Consul Load-Balancing made simple
https://fabiolb.net
MIT License
7.26k stars 616 forks source link

sometime 404 #847

Open Leadrive opened 2 years ago

Leadrive commented 2 years ago

I have three ECS, every ECS had install nginx to access the http request.

My http service use nomad to manage. this is the nomad config.

job "httpcard" {
  datacenters = ["dc1"]
  type = "service"

  group "httpcardg" {
    count = 3
    network {
      port "http" {
        static = 8482
        to = 8482
      }
    }

    service {
      name = "httpcards"
      tags = ["urlprefix-/"]
      port = "http"
      check {
        name     = "health"
        type     = "http"
        path     = "/api/card/health"
        interval = "10s"
        timeout  = "2s"
      }
    }

    restart {
      attempts = 2
      interval = "30m"
      delay = "15s"
      mode = "fail"
    }

    task "httpcardt" {
      env {
        REDIS_ADDR = "172.16.0.2:6379"
        REDIS_PASSWORD = "xxxx"
      }
      user = "develop"
      driver = "raw_exec"
      config {
        command = "/develop/http_card/httpCard"
      }
    }
  }
}

I want to use fabio to route the request to my http service http_card, so I set the proxy in nginx.conf.

                location /api/card {
                        proxy_pass http://127.0.0.1:9999/api/card;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                }

/api/card is the URL.

fabio routes will have

1   httpcards   /   http://172.16.0.4:8482/     33.33%
2   httpcards   /   http://172.16.0.2:8482/     33.33%
3   httpcards   /   http://172.16.0.12:8482/        33.33%

fabio sometime can tranfer the http request, sometime report 404

ketzacoatl commented 2 years ago

@Leadrive does the backend return a 404 in these cases, or only fabio? Can you look at fabio's logs to determine the service health or additional info about what state the services and routes are in?