Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fabio proxy for consul not work, log show no route #212

Closed
cjdxlgb opened this issue Jan 11, 2017 · 13 comments
Closed

fabio proxy for consul not work, log show no route #212

cjdxlgb opened this issue Jan 11, 2017 · 13 comments

Comments

@cjdxlgb
Copy link

cjdxlgb commented Jan 11, 2017

@magiconair
my english is poor, and i need some help from you, can you help me?
I regist a service in consul like this and success:

[{"Node":{"Node":"localhost.localdomain","Address":"10.1.22.12","TaggedAddresses":{"lan":"10.1.22.12","wan":"10.1.22.12"},"CreateIndex":4,"ModifyIndex":11},"Service":{"ID":"redis31","Service":"redis31","Tags":["/website/test","website/test","/website","website","/website/","website/","hehe/website"],"Address":"172.168.11.16","Port":9190,"EnableTagOverride":true,"CreateIndex":10,"ModifyIndex":11},"Checks":[{"Node":"localhost.localdomain","CheckID":"serfHealth","Name":"Serf Health Status","Status":"passing","Notes":"","Output":"Agent alive and reachable","ServiceID":"","ServiceName":"","CreateIndex":4,"ModifyIndex":4},{"Node":"localhost.localdomain","CheckID":"service:redis31","Name":"Service 'redis31' check","Status":"passing","Notes":"","Output":"HTTP GET http://172.168.11.16:9190/website/test: 200 OK Output: {\"success\":false,\"resultCode\":null,\"message\":null,\"dataMap\":null}","ServiceID":"redis31","ServiceName":"redis31","CreateIndex":10,"ModifyIndex":11}]}]

and i start fabio by default:

2017/01/11 11:22:37 [INFO] Version 1.3.5 starting
2017/01/11 11:22:37 [INFO] Go runtime is go1.7.3
2017/01/11 11:22:37 [INFO] Using routing strategy "rnd"
2017/01/11 11:22:37 [INFO] Using routing matching "prefix"
2017/01/11 11:22:37 [INFO] Setting GOGC=800
2017/01/11 11:22:37 [INFO] Setting GOMAXPROCS=4
2017/01/11 11:22:37 [INFO] Metrics disabled
2017/01/11 11:22:37 [INFO] consul: Connecting to "localhost:8500" in datacenter "dc1"
2017/01/11 11:22:37 [INFO] Admin server listening on ":9998"
2017/01/11 11:22:37 [INFO] HTTP proxy listening on :9999
2017/01/11 11:22:37 [INFO] consul: Using dynamic routes
2017/01/11 11:22:37 [INFO] consul: Using tag prefix "urlprefix-"
2017/01/11 11:22:37 [INFO] consul: Watching KV path "/fabio/config"
2017/01/11 11:22:37 [INFO] consul: Health changed to #25
2017/01/11 11:22:37 [INFO] consul: Manual config changed to #1
2017/01/11 11:22:37 [INFO] Updated config to
2017/01/11 11:22:37 [INFO] consul: Registered fabio with id "fabio-localhost.localdomain-9998"
2017/01/11 11:22:37 [INFO] consul: Registered fabio with address "10.1.22.12"
2017/01/11 11:22:37 [INFO] consul: Registered fabio with tags ""
2017/01/11 11:22:37 [INFO] consul: Registered fabio with health check to "http://[10.1.22.12]:9998/health"
2017/01/11 11:22:37 [INFO] consul: Health changed to #27
2017/01/11 11:22:38 [INFO] consul: Health changed to #29
**2017/01/11 11:22:48 [WARN] No route for 10.1.22.12:9999/website/test**

I read the doc of fabio github quickstart, but i can not understand what the urlprefix means and how to work, i and many tags and consul, but it is not work.

thank you very much!

@magiconair
Copy link
Contributor

@cjdxlgb Try using only one tag urlprefix-/website

By adding urlprefix- to the front fabio can find the tag and understand it.

@cjdxlgb
Copy link
Author

cjdxlgb commented Jan 11, 2017

@magiconair
it works, thank very much, I spend about 8 hours on it, so hard...

by the way, is fabio enable to do session sticky like nginx?

thank you, best wish from china.

@magiconair
Copy link
Contributor

@cjdxlgb I'm glad it works now. No sticky session support at this point but I am thinking about it.

@magiconair
Copy link
Contributor

@cjdxlgb Greetings from Amsterdam, NL :)

@cjdxlgb
Copy link
Author

cjdxlgb commented Jan 11, 2017

@magiconair
thank you for reply.
no sticky session support,
so is there any other way to keep session status, if I use fabio to load balance for a stateful services.

@magiconair
Copy link
Contributor

@cjdxlgb Right now there isn't but I generally add features based on demand; when more people ask I'll add it. Please follow issue #202 for updates.

@cjdxlgb
Copy link
Author

cjdxlgb commented Jan 11, 2017

thank you so much!

last 2 question:
1, if my target services access by different url like this:
/website/test
/website2/test
/website/website2/test
i want to use fabio proxy this 3 service, how can i config the tags to register to consul, do it is support?

2, i read fabio.properties, there is no config like the weigth in nginx, i want to proxy for each service with different wight, do it is support?

where cant i find more fabio document besides this github site.

@cjdxlgb
Copy link
Author

cjdxlgb commented Jan 11, 2017

@magiconair as last reply.

@magiconair
Copy link
Contributor

@cjdxlgb

  1. You use multiple tags, e.g. urlprefix-/website/test, urlprefix-/website2/test and urlprefix-/website/website2/test

  2. You can use the manual overrides to assign weights to different routes. See https://github.com/eBay/fabio/wiki/Features#traffic-shaping

  3. Check the wiki https://github.com/eBay/fabio/wiki

@cjdxlgb
Copy link
Author

cjdxlgb commented Jan 12, 2017

@magiconair

Thank you for your patience.

  1. Sorry, I reply you by google translate, I think I did not express what I meant.
    My target service in 3 different host:port and access by different url prefix as bellow, they support same service and just access by different url prefix: /website/test, /website2/test, /website/website2/test

Now I want to use fabio proxy for this 3 service, and I want to use same url access this 3 service through fabio. for example: 10.1.21.22:9999/website/test, fabio will load banlance to 3 target service.

How can I do, register 3 service with different serviceId or register 1 service with 3 tags, if I register 1 service with 3 tags, how can I config 3 different Health Check http url.

I hope you understand what I mean.

  1. I read the wiki, what the mean is add the config to fabio.properties like this?
    route weight service-b www.kjca.dev/auth/ weight 0.05 tags "version-15,dc-fra"

@cjdxlgb
Copy link
Author

cjdxlgb commented Jan 12, 2017

@magiconair

I try like this:

curl -X PUT -d '{"ID": "redis30","Name": "redis30","Tags": ["urlprefix-/website/","urlprefix-/website2/"],"Address": "172.168.11.16","Port": 9190,"EnableTagOverride": false, "Check":{"id": "Health30","name": "Health30","http": "http://172.168.11.16:9190/website/test","interval": "5s","timeout": "2s"}}' http://10.1.22.12:8500/v1/agent/service/register
curl -X PUT -d '{"ID": "redis31","Name": "redis31","Tags": ["urlprefix-/website/","urlprefix-/website2/"],"Address": "172.168.11.16","Port": 9290,"EnableTagOverride": false, "Check":{"id": "Health31","name": "Health31","http": "http://172.168.11.16:9290/website2/test","interval": "5s","timeout": "2s"}}' http://10.1.22.12:8500/v1/agent/service/register


2017/01/12 11:55:51 [INFO] Version 1.3.5 starting
2017/01/12 11:55:51 [INFO] Go runtime is go1.7.3
2017/01/12 11:55:51 [INFO] Using routing strategy "rnd"
2017/01/12 11:55:51 [INFO] Using routing matching "prefix"
2017/01/12 11:55:51 [INFO] Setting GOGC=800
2017/01/12 11:55:51 [INFO] Setting GOMAXPROCS=4
2017/01/12 11:55:51 [INFO] Metrics disabled
2017/01/12 11:55:51 [INFO] consul: Connecting to "10.1.22.12:8500" in datacenter "dc1"
2017/01/12 11:55:51 [INFO] Admin server listening on ":9998"
2017/01/12 11:55:51 [INFO] HTTP proxy listening on :9999
2017/01/12 11:55:51 [INFO] consul: Using dynamic routes
2017/01/12 11:55:51 [INFO] consul: Using tag prefix "urlprefix-"
2017/01/12 11:55:51 [INFO] consul: Watching KV path "/fabio/config"
2017/01/12 11:55:51 [INFO] consul: Health changed to #26
2017/01/12 11:55:51 [INFO] consul: Manual config changed to #1
2017/01/12 11:55:51 [INFO] Updated config to
2017/01/12 11:55:51 [INFO] Updated config to
route add redis31 /website2/ http://172.168.11.16:9290/ tags "urlprefix-/website/,urlprefix-/website2/"
route add redis30 /website2/ http://172.168.11.16:9190/ tags "urlprefix-/website/,urlprefix-/website2/"
route add redis31 /website/ http://172.168.11.16:9290/ tags "urlprefix-/website/,urlprefix-/website2/"
route add redis30 /website/ http://172.168.11.16:9190/ tags "urlprefix-/website/,urlprefix-/website2/"
2017/01/12 11:55:51 [INFO] consul: Registered fabio with id "fabio-testserver-9998"
2017/01/12 11:55:51 [INFO] consul: Registered fabio with address "10.1.22.12"
2017/01/12 11:55:51 [INFO] consul: Registered fabio with tags ""
2017/01/12 11:55:51 [INFO] consul: Registered fabio with health check to "http://[10.1.22.12]:9998/health"
2017/01/12 11:55:51 [INFO] consul: Health changed to #32

And I access http://10.1.22.12:9999/website2/test, have 50% return http 404, I think it is route to wrong service.

@magiconair
Copy link
Contributor

fabio does not support path rewriting. If you need to access a service under /website then it must have an HTTP handler for /website. Hence, your three different services need to have handlers for all URLs on which they should respond. Then you can register all three URLs with fabio. Otherwise, register only the prefixes they do support but then there won't be any load balancing between services of different prefixes.

To test this make sure the following works:

curl -i http://172.168.11.16:9290/website/test
curl -i http://172.168.11.16:9290/website2/test
curl -i http://172.168.11.16:9290/website/website2/test

and

curl -i http://172.168.11.16:9190/website/test
curl -i http://172.168.11.16:9190/website2/test
curl -i http://172.168.11.16:9190/website/website2/test

@cjdxlgb
Copy link
Author

cjdxlgb commented Jan 13, 2017

@magiconair
ok, thanks.
I know what your means, my 3 service only support one of the 3 URLs, so if fabio does not support path rewriting like nginx, it does not support load balanceing for them. fabio only load balance for the service access by same url prefix. right?

You forgot to reply to the question 2 about load wight:

I read the wiki, what the mean is add the config to fabio.properties like this?
route weight service-b www.kjca.dev/auth/ weight 0.05 tags "version-15,dc-fra".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants