Fabio on Nomad with consul

553 views
Skip to first unread message

ANKIT ROHILLA

unread,
Jul 3, 2018, 6:02:48 AM7/3/18
to Nomad
Hi All,
I am having issues with fabio setup on top of consul.
I'll tell you my use case directly, its a very basic one.
I have two nomad clients running an instance of nginx server each. This server is run as a service (specified in .nomad job file) and the client_port exposed is 80. No tags were specified in .nomad file. My nginx service has been recognized by consul and in the consul_UI it is showing those two clients on which this service is running, which is perfectly fine. Also when I use 'dig @127.0.0.1 -p 8600 service_name.service.consul', it returns a valid response.
Now I want to use fabio to handle the requests for this server. I have started fabio on the same node on which consul server is running. So, I read in the official doc that I will have to register the service first on a consul API with 'name', 'port' and 'tags' key. And the format of 'tags' is "urlprefix-host/path".
Here comes my question, according to my use case what should I write in place of host/path. Do I have to write all the client_IPs on which nginx is running, i.e., register separately for all hosts or clients (as we call in nomad)?
And for the 'port' key, what if the ports are not statically defined, i.e., what if nomad is selecting the ports on its own randomly which happens by default?

FYI I am running those nginx server instances inside a container in the nodes. So, the mapping of container_port to node_port should be random and not static.
If possible, take me through the steps that I need to do to configure all this stuff.

Please help, I am stuck at this point. Nowhere to ask. Main thing being how to setup fabio for a service which is getting displayed in consul_UI.

Thanks and Regards
Ankit R

Matt Veitas

unread,
Jul 5, 2018, 8:40:37 PM7/5/18
to Nomad
Try the following in your service stanza:
tags = ["type:api", "urlprefix-/my-path", "urlprefix-/my-other-path"]

Fabio should pick up these tags and automatically start to route traffic to them (Fabio will only route to instances that have a passing healthcheck in Consul)

Ankit Rohilla

unread,
Jul 16, 2018, 4:15:36 AM7/16/18
to Nomad
Thanks for the reply, I've setup fabio successfully now.
One more question I had.
Fabio is a no-DSR model, means every request and response from a client and server will go through Fabio. So, Fabio must maintain a requestconnection table as to which request went to which server and some info related to that request, like where to send the response, on which server to forward request, some request ID for identification. I am unable to get that part, where it stores all the connection info. I mean it might delete the entries when a request is resolved but still how to access that information?

Thanks and Regards
Ankit R

Akash Kumar

unread,
Dec 2, 2019, 6:25:34 AM12/2/19
to Nomad

 {

"service": {

"ID": "abcNode1",

"name": "abc",

"address": "10.10.10.1",

"port": 000,

"tags": ["urlprefix-eg.service.consul/","urlprefix-eg.abc.com/"],

"check": {

"id": "abcNode1",

"name": "SSH TCP on port 000",

"tcp": "10.10.10.1:000",

"interval": "10s",

"timeout": "1s"

Reply all
Reply to author
Forward
0 new messages