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

Use Address instead of ServiceAddress? #88

Closed
chy168 opened this issue Apr 22, 2016 · 7 comments
Closed

Use Address instead of ServiceAddress? #88

chy168 opened this issue Apr 22, 2016 · 7 comments
Milestone

Comments

@chy168
Copy link

chy168 commented Apr 22, 2016

Hello,

I'm trying to integrate fabio with my own service with Consul.
I found Consul might not return "ServiceAddress" when we don't set service.address in Consul definition.

It might cause proxy error, because fabio now depends on "ServiceAddress" as the dest of traffic.

For example:

Consul definition WITH "address" attribute:

{"service": {"name": "web", "tags": ["urlprefix-/test1"], "address": "172.17.0.4", "port": 8000, "check": {"script": "curl localhost:8000 >/dev/null 2>&1", "interval": "5s"}}}

consul return:

$ curl -XGET http://172.17.0.1:8500/v1/catalog/service/web
[
  {
    "Node": "6453bcec8524",
    "Address": "172.17.0.4",
    "ServiceID": "web",
    "ServiceName": "web",
    "ServiceTags": [
      "urlprefix-/test1"
    ],
    "ServiceAddress": "172.17.0.4",
    "ServicePort": 8000,
    "ServiceEnableTagOverride": false,
    "CreateIndex": 22226,
    "ModifyIndex": 22227
  }
]

Consul definition WITHOUT "address" attribute:

{"service": {"name": "web", "tags": ["urlprefix-/test1"], "port": 8000, "check": {"script": "curl localhost:8000 >/dev/null 2>&1", "interval": "5s"}}}

consul return:

$ curl -XGET http://172.17.0.1:8500/v1/catalog/service/web
[
  {
    "Node": "6453bcec8524",
    "Address": "172.17.0.4",
    "ServiceID": "web",
    "ServiceName": "web",
    "ServiceTags": [
      "urlprefix-/test1"
    ],
    "ServiceAddress": "",
    "ServicePort": 8000,
    "ServiceEnableTagOverride": false,
    "CreateIndex": 22116,
    "ModifyIndex": 22117
  }
]

For non-fixed consul definition file in Docker image, could we just leverage Address instead of ServiceAddress? is that possible?

Please advice! thank you! :)

@magiconair
Copy link
Contributor

This vaguely rings a bell but I need to dig through the consul documentation again why that is. For now, I suggest to provide the service address.

@chy168
Copy link
Author

chy168 commented Apr 23, 2016

Thanks for your replay. I also try to find the document describe about this behavior but in vain. I would like to help on this topic, please let me know if any clue we can dig into or do any experiment.

magiconair added a commit that referenced this issue Apr 26, 2016
* Use the consul node address if the service did not register an address
@magiconair
Copy link
Contributor

The consul documentation for services https://www.consul.io/docs/agent/services.html says that the service address is optional.

The address field can be used to specify a service-specific IP address. By default, the IP address of the agent is used, and this does not need to be provided.

I've added a change to use the address field if the ServiceAddress is empty. Could you test whether that works for you?

@mazhack
Copy link

mazhack commented Apr 26, 2016

I use ServiceAddress for health check and expose an old IIS web application on windows server 12, consul agent host and windows host are different, so if you change ServiceAddress to Address my prod environment will be break.

So, is good for me that fabio uses Address only if ServiceAddress is empty.

@magiconair
Copy link
Contributor

@mazhack ServiceAddress takes precedence over Address.

@magiconair magiconair added this to the 1.1.2 milestone Apr 27, 2016
@chy168
Copy link
Author

chy168 commented Apr 30, 2016

Hi @magiconair,
Sorry for late reply, I've tested this scenario on my end via the latest release 1.1.2.
Thanks for your time and fabio rocks!!

@codekoala
Copy link

codekoala commented Jul 20, 2017

I could definitely use the option to select Address over ServiceAddress. I'm trying to use nomad to run some services, and it currently doesn't seem to expose a way to specify ServiceAddress (because nomad decides where to run each service). I'd be happy to learn that I'm mistaken if that's the case.

Anyway, for my use case, Address is the server's private IP address and ServiceAddress is the server's public IP address. In order to save on bandwidth charges and improve response times, I would like to use the Address value. Also, almost all ports must be locked down against all public traffic (with exceptions for 22, 80, 443, etc).

Here's an example of what I'm seeing in consul's service catalog:

[
{
  "ID": "11b53a97-489e-1d5f-8af3-91ffc29d903e",
  "Node": "node-01.domain.com",
  "Address": "192.168.0.1",
  "Datacenter": "us-west",
  "TaggedAddresses": {
    "lan": "192.168.0.1",
    "wan": "192.168.0.1"
  },
  "NodeMeta": {},
  "ServiceID": "_nomad-executor-e0a22377-8362-83d8-40e5-ca12c9103150-server-something-urlprefix-something.domain.com/",
  "ServiceName": "nomad-ui",
  "ServiceTags": [
    "prom",
    "urlprefix-something.domain.com/"
  ],
  "ServiceAddress": "172.104.a.b",
  "ServicePort": 3000,
  "ServiceEnableTagOverride": false,
  "CreateIndex": 19297,
  "ModifyIndex": 19297
},
{
  "ID": "b6aece04-f1d0-3811-63d3-2392102b3905",
  "Node": "node-02.domain.com",
  "Address": "192.168.0.2",
  "Datacenter": "us-west",
  "TaggedAddresses": {
    "lan": "192.168.0.2",
    "wan": "192.168.0.2"
  },
  "NodeMeta": {},
  "ServiceID": "_nomad-executor-1ddb350c-7656-e502-50b8-b48f455b645a-server-something-urlprefix-something.domain.com/",
  "ServiceName": "nomad-ui",
  "ServiceTags": [
    "prom",
    "urlprefix-something.domain.com/"
  ],
  "ServiceAddress": "172.104.y.z",
  "ServicePort": 3000,
  "ServiceEnableTagOverride": false,
  "CreateIndex": 19296,
  "ModifyIndex": 19296
}
]

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

No branches or pull requests

4 participants