fabiolb / fabio

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

fabio url prefix tag not working with anything except "urlprefix-/" in nomad jobs #406

Open cl0udgeek opened 6 years ago

cl0udgeek commented 6 years ago

I'm having in issue where I can't get my nomad job to route with Fabio with anything except /

for example...this works:

        cpu    = 1500
        memory = 2048

        network {
          mbits = 50

          port "httpcontrolplane" {

          }
        }
      }

      service {
        name = "cpmamadou"
        tags = ["urlprefix-/"]

        port = "httpcontrolplane"

        check {
          type     = "http"
          port     = "httpcontrolplane"
          path     = "/health"
          interval = "10s"
          timeout  = "2s"
        }
      }

but this errors out..

        cpu    = 1500
        memory = 2048

        network {
          mbits = 50

          port "httpcontrolplane" {

          }
        }
      }

      service {
        name = "cpmamadou"
        tags = ["urlprefix-/cpm"]

        port = "httpcontrolplane"

        check {
          type     = "http"
          port     = "httpcontrolplane"
          path     = "/health"
          interval = "10s"
          timeout  = "2s"
        }
      }

and it throws this error when I go the link:


This application has no explicit mapping for /error, so you are seeing this as a fallback.

Tue Dec 12 01:24:33 UTC 2017
There was an unexpected error (type=Not Found, status=404).
No message available

this error is happening on all of my nomad jobs....a url prefix like this works: urlprefix-/ but not with anything after /.

why is this happening?

magiconair commented 6 years ago

Something wants to request /error but there is no mapping since your service is only announcing /cpm. Everything else will return a 404 Not Found. You need to have a service that can handle /error or add a second tag on the cpmservice if it handles it.

— Frank Schröder

On 12. Dec 2017, at 02:28, k1ng87 notifications@github.com wrote:

I'm having in issue where I can't get my nomad job to route with Fabio with anything except /

for example...this works:

    cpu    = 1500
    memory = 2048

    network {
      mbits = 50

      port "httpcontrolplane" {

      }
    }
  }

  service {
    name = "cpmamadou"
    tags = ["urlprefix-/"]

    port = "httpcontrolplane"

    check {
      type     = "http"
      port     = "httpcontrolplane"
      path     = "/health"
      interval = "10s"
      timeout  = "2s"
    }
  }

but this errors out..

    cpu    = 1500
    memory = 2048

    network {
      mbits = 50

      port "httpcontrolplane" {

      }
    }
  }

  service {
    name = "cpmamadou"
    tags = ["urlprefix-/cpm"]

    port = "httpcontrolplane"

    check {
      type     = "http"
      port     = "httpcontrolplane"
      path     = "/health"
      interval = "10s"
      timeout  = "2s"
    }
  }

and it throws this error when I go the link:

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Tue Dec 12 01:24:33 UTC 2017 There was an unexpected error (type=Not Found, status=404). No message available```

this error is happening on all of my nomad jobs....a url prefix like this works: urlprefix-/ but not with anything after /.

why is this happening? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

cl0udgeek commented 6 years ago

I'm a bit confused on that then...so if I configure the tag like this tags = ["urlprefix-/"]...shouldn't I get the same error then?

this is the case on all nomad jobs too....for example...on another job if I tag it like this, tags = ["urlprefix-/"]...that works when I go to this link: http://nomad-clients-dev-e.aws-dqa.cb.com/jolokia/search/kafka.consumer

but if I tag it like this: tags = ["urlprefix-/logstashjmx"]...and then go to this link: http://nomad-clients-dev-e.aws-dqa.cb.com/logstashjmx/jolokia/search/kafka.consumer...I get this 404 error:

404 Not Found

No context found for request

all the health checks in consul are up and running and in my fabio routes I do see this:

| Service | Source | Dest | Options | Weight

1 | logstashparser | /logstashjmx | http://10.46.41.38:29936/ |   | 2.22%

talksinmath commented 6 years ago

I'm running into the same problem. I have jobs deployed via nomad and can only reach the exact path exposed viaurl-prefix .

E.g., I have a restheart running (exposes rest-interface to mongodb).

Route via fabio:

restheart | /restheart | http://127.0.0.1:25200/ -- | -- | --

When trying to access restheart via fabio, only / is reachable. The UI that is running under /browser is unreachable.

Maybe I'm making a beginners mistake, but any help is greatly appreciated.

GastroGee commented 5 years ago

i have this same problem as well. I have a grafana service running with this configuration service { name = "grafana" port = "http" tags = ["urlprefix-/"] check { name = "Grafana HTTP" type = "http" path = "/api/health" interval = "5s" timeout = "2s" check_restart { limit = 2 grace = "60s" ignore_warnings = false } } }

as soon as i change it to service { name = "grafana" port = "http" tags = ["urlprefix-/grafana"] check { name = "Grafana HTTP" type = "http" path = "/api/health" interval = "5s" timeout = "2s" check_restart { limit = 2 grace = "60s" ignore_warnings = false } } }

i am not able to reach the service

aaronhurt commented 5 years ago

@GastroGee @talksinmath @k1ng87 ...

We're using nomad and fabio for multiple deployments with path based routing. This is probably reaching your container but not at the path the container expects. You probably want the tags to look like:

tags = [ "urlprefix-/foo/ strip=/foo" ]

With this tag the underlying service will get the request on / and not /foo which it doesn't know how to handle.

sksegha commented 5 years ago

it still does not work with the tag you provided @leprechau

However i think the problem might be with the grafana configuration itself.

Thanks

sksegha commented 5 years ago

@leprechau this actually worked, the problem was with the local service (grafana) that i had running in the cluster. As soon as i updated the root_url config in grafana to reveal the path (https://{server}:{port}/grafana); the service came up with no issues

rroque6428 commented 2 years ago

Also, if you are using the Nomad, 'root_url_config' can be set using:

  ...
    task "server" {
      driver = "docker"

      config {
        image = "grafana/grafana"
        ports = ["http"]
      }

      env {
        GF_LOG_LEVEL = "DEBUG"
        GF_LOG_MODE = "console"
        GF_SERVER_HTTP_PORT = "${NOMAD_PORT_http}"
        GF_SERVER_ROOT_URL = "%(protocol)s://%(domain)s:%(http_port)s/grafana"
        GF_PATHS_PROVISIONING = "/local/provisioning"
      }
....