Skip to content

Commit

Permalink
Added -registry.consul.register.tlsskipverify flag
Browse files Browse the repository at this point in the history
When serving the UI/API over HTTPS, the fabio consul
health check will most likely fail as it's trying to
connect to the page over its IP. Most certificates don't
include IP SANs. This flag allows users to toggle whether
or not to skip TLS verification for this particular check.
  • Loading branch information
Ginja committed Apr 22, 2017
1 parent 993e448 commit 0db7b84
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 16 deletions.
27 changes: 14 additions & 13 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,18 @@ type File struct {
}

type Consul struct {
Addr string
Scheme string
Token string
KVPath string
TagPrefix string
Register bool
ServiceAddr string
ServiceName string
ServiceTags []string
ServiceStatus []string
CheckInterval time.Duration
CheckTimeout time.Duration
CheckScheme string
Addr string
Scheme string
Token string
KVPath string
TagPrefix string
Register bool
ServiceAddr string
ServiceName string
ServiceTags []string
ServiceStatus []string
CheckInterval time.Duration
CheckTimeout time.Duration
CheckScheme string
CheckTLSSkipVerify bool
}
1 change: 1 addition & 0 deletions config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ func load(cmdline, environ, envprefix []string, props *properties.Properties) (c
f.StringSliceVar(&cfg.Registry.Consul.ServiceStatus, "registry.consul.service.status", defaultConfig.Registry.Consul.ServiceStatus, "valid service status values")
f.DurationVar(&cfg.Registry.Consul.CheckInterval, "registry.consul.register.checkInterval", defaultConfig.Registry.Consul.CheckInterval, "service check interval")
f.DurationVar(&cfg.Registry.Consul.CheckTimeout, "registry.consul.register.checkTimeout", defaultConfig.Registry.Consul.CheckTimeout, "service check timeout")
f.BoolVar(&cfg.Registry.Consul.CheckTLSSkipVerify, "registry.consul.register.checkTLSSkipVerify", defaultConfig.Registry.Consul.CheckTLSSkipVerify, "service check TLS verifcation")
f.IntVar(&cfg.Runtime.GOGC, "runtime.gogc", defaultConfig.Runtime.GOGC, "sets runtime.GOGC")
f.IntVar(&cfg.Runtime.GOMAXPROCS, "runtime.gomaxprocs", defaultConfig.Runtime.GOMAXPROCS, "sets runtime.GOMAXPROCS")
f.StringVar(&uiListenerValue, "ui.addr", defaultValues.UIListenerValue, "Address the UI/API is listening on")
Expand Down
7 changes: 7 additions & 0 deletions config/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,13 @@ func TestLoad(t *testing.T) {
return cfg
},
},
{
args: []string{"-registry.consul.register.checkTLSSkipVerify=true"},
cfg: func(cfg *Config) *Config {
cfg.Registry.Consul.CheckTLSSkipVerify = true
return cfg
},
},
{
args: []string{"-registry.consul.register.tags", "a, b, c, "},
cfg: func(cfg *Config) *Config {
Expand Down
10 changes: 10 additions & 0 deletions fabio.properties
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,16 @@
#
# registry.consul.register.checkTimeout = 3s

# registry.consul.register.checkTLSSkipVerify configures whether or not to skip TLS verification for the health check.
#
# Fabio registers an http health check on http(s)://${ui.addr}/health
# and this value tells consul whether or not to verify the TLS certificate
# if it's being served over HTTPS
#
# The default is
#
# registry.consul.register.checkTLSSkipVerify = false


# metrics.target configures the backend the metrics values are
# sent to.
Expand Down
7 changes: 4 additions & 3 deletions registry/consul/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ func serviceRegistration(cfg *config.Consul) (*api.AgentServiceRegistration, err
Port: port,
Tags: cfg.ServiceTags,
Check: &api.AgentServiceCheck{
HTTP: checkURL,
Interval: cfg.CheckInterval.String(),
Timeout: cfg.CheckTimeout.String(),
HTTP: checkURL,
Interval: cfg.CheckInterval.String(),
Timeout: cfg.CheckTimeout.String(),
TLSSkipVerify: cfg.CheckTLSSkipVerify,
},
}

Expand Down

0 comments on commit 0db7b84

Please sign in to comment.