fabiolb / fabio

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

Fabio Proxy (localhost:9999) Showing Blank White Screen #752

Closed BLuchterhand closed 4 years ago

BLuchterhand commented 4 years ago

I'll preface this with the fact that I'm learning; I believe I'm missing something fundamental.

I'm running Consul and Fabio on a Vagrant environment. A Consul server and a Fabio instance are running on one VM, and a Consul agent and my small web server is hosted on another VM. I have forwarded the appropriate ports to view both the Consul and Fabio UIs, and I've also set up health checks and routing for the web server:

image

image

The health check that is registered on the consul agent:

{"service":
  {"name": "web",
   "port": 8091,
   "check": {
      "args": ["curl", "localhost"],
      "interval": "5s"
    },
   "tags": ["urlprefix-/"]
  }
}

And finally the web-server when directly entering the port information: image

Fabio displays the correct routing information in its UI, but going to localhost:9999/ sends me to a completely blank webpage, not Firefox's "Unable to connect" page or the python SimpleHTTPServer that is running at the correctly routed port.

The Fabio instance that is running is not using any config or properties file, it's a fresh install with no config.

Is there something very basic that I'm missing here?

aaronhurt commented 4 years ago

To make it even easier, there is a simple example application that can be used for this kind of testing as well: https://github.com/fabiolb/fabio-example

On a machine with go installed you can simply go get github.com/fabiolb/fabio-example and then have a command-line tool called fabio-example that will register itself with consul, add the proper tags and serve up simple payload.

To your case explicitly, could you paste the dump of curl localhost:9998/api/routes?raw or wherever Fabio is running.

aaronhurt commented 4 years ago

Very simple test example using a few terminal windows on a local host...

Terminal 1: consul agent -dev

Terminal 2: fabio

Terminal 3: fabio-example -prefix /

Terminal 4: fabio-example -addr :5001 -prefix /foo

Terminal 5:

charlie:~ ahurt$ curl localhost:9998/api/routes?raw
route add fabio-example /foo http://127.0.0.1:5001/
route add fabio-example / http://127.0.0.1:5000/
charlie:~ ahurt$ curl localhost:9999/asdf
Serving /asdf from fabio-example on 127.0.0.1:5000
charlie:~ ahurt$ curl localhost:9999/
Serving / from fabio-example on 127.0.0.1:5000
charlie:~ ahurt$ curl localhost:9999/foo
Serving /foo from fabio-example on :5001
charlie:~ ahurt$
BLuchterhand commented 4 years ago

@leprechau Mine spits out: route add web / http://10.0.15.31:8091/

aaronhurt commented 4 years ago

Next question, can Fabio talk to 10.0.15.31:8091? You can also trace the request in Fabio itself.

Using my previous example if you started Fabio with fabio -log.level=trace and then did the following request curl -v -H 'Trace: testing' http://localhost:9999/foo you should see this in the Fabio logs...

2020/02/12 11:17:43 [TRACE] testing Tracing localhost:9999/foo
2020/02/12 11:17:43 [TRACE] testing Matching hosts: []
2020/02/12 11:17:43 [TRACE] testing Match /foo
2020/02/12 11:17:43 [TRACE] testing Routing to service fabio-example on http://127.0.0.1:5001/

More information here: https://fabiolb.net/faq/request-tracing/

BLuchterhand commented 4 years ago

No it looks like it can't access it (my setup uses the hosts 9991 port forwarded to Fabio's 9999 port):

*   Trying 127.0.0.1...
* TCP_NODELAY set
* connect to 127.0.0.1 port 9991 failed: Connection refused
* Failed to connect to localhost port 9991: Connection refused
* Closing connection 0
curl: (7) Failed to connect to localhost port 9991: Connection refused
BLuchterhand commented 4 years ago

Ah, and refreshing the localhost:9991 address in the browser just spit this out: 2020/02/12 17:24:07 [ERROR] dial tcp 10.0.15.31:8091: connect: connection refused

pschultz commented 4 years ago

You have to either change the networking so that the VMs can directly connect to each other, or change the service registration to some address that is reachable from the fabio VM (using the "address" field).

I.e., login to the fabio VM, figure out which curl command works to request your HTML page, then use the address and port from the curl command in the service definition.

BLuchterhand commented 4 years ago

So I believe I was pointing the service check to the wrong port; I had it pointing to the port of the VM running the webserver instead of port that it was forwarded to on the host machine... Thanks for the help!