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 can connect to Consul using TLS for secure communication. #391

Closed
wants to merge 6 commits into from

Conversation

jrasell
Copy link
Contributor

@jrasell jrasell commented Nov 20, 2017

This change updates Fabio's configuration parameters to allow use and specification of TLS certificates for HTTPS. In Consul setups where full TLS is configured using CA private this allows Fabio to work in a secure manner.

I have tested this change locally with a Consul TLS setup; log fragments are shown below to provide further detail:

./fabio -registry.consul.caFile=/Users/rasellj/opt/hashicorp/ca/rasellj-ca.pem -registry.consul.enableSSL -registry.consul.keyFile=/Users/rasellj/opt/hashicorp/consul/consul-server-key.pem -registry.consul.certFile=/Users/rasellj/opt/hashicorp/consul/consul-server.pem -registry.consul.verifySSL
"EnableSSL": true,
"VerifySSL": true,
"CAFile": "/Users/rasellj/opt/hashicorp/ca/rasellj-ca.pem",
"CertFile": "/Users/rasellj/opt/hashicorp/consul/consul-server.pem",
"KeyFile": "/Users/rasellj/opt/hashicorp/consul/consul-server-key.pem"
2017/11/20 09:44:50 [INFO] Version v1.5.3-10-g5b2fe34 starting
2017/11/20 09:44:50 [INFO] Go runtime is go1.9
2017/11/20 09:44:50 [INFO] Metrics disabled
2017/11/20 09:44:50 [INFO] Setting GOGC=800
2017/11/20 09:44:50 [INFO] Setting GOMAXPROCS=8
2017/11/20 09:44:50 [INFO] consul: Connecting to "localhost:8500" in datacenter "dc1"
2017/11/20 09:44:50 [INFO] Admin server access mode "rw"
2017/11/20 09:44:50 [INFO] Admin server listening on ":9998"
2017/11/20 09:44:50 [INFO] Waiting for first routing table
2017/11/20 09:44:50 [INFO] consul: Using dynamic routes
2017/11/20 09:44:50 [INFO] consul: Using tag prefix "urlprefix-"
2017/11/20 09:44:50 [INFO] consul: Watching KV path "/fabio/config"
2017/11/20 09:44:53 [INFO] consul: Registered fabio with id "REDACTED-9998"
2017/11/20 09:44:53 [INFO] consul: Registered fabio with address "10.210.90.45"
2017/11/20 09:44:53 [INFO] consul: Registered fabio with tags ""
2017/11/20 09:44:53 [INFO] consul: Registered fabio with health check to "http://[10.210.90.45]:9998/health"
2017/11/20 09:44:54 [INFO] consul: Manual config changed to #1
2017/11/20 09:44:54 [INFO] HTTP proxy listening on :9999
2017/11/20 09:44:54 [INFO] Access logging disabled
2017/11/20 09:44:54 [INFO] Using routing strategy "rnd"
2017/11/20 09:44:54 [INFO] Using route matching "prefix"
2017/11/20 09:44:54 [INFO] consul: Health changed to #6

Feedback would be appreciated, and any changes requested will be acted upon promptly.

Closes #276

This change updates Fabio's configuration parameters to allow use
and specification of TLS certificates for HTTPS. In Consul setups
where full TLS is configured using CA private this allows Fabio
to work in a secure manner.

Closes fabiolb#276
@CLAassistant
Copy link

CLAassistant commented Nov 20, 2017

CLA assistant check
All committers have signed the CLA.

@jrasell
Copy link
Contributor Author

jrasell commented Nov 20, 2017

The test failures seem to be sporadic and I do not believe they are related to my changes.

@jrasell
Copy link
Contributor Author

jrasell commented Dec 4, 2017

@magiconair would it be possible to get some feedback on this PR?

@magiconair
Copy link
Contributor

Yes. I’ll have a look later today. Sorry for the delay

@magiconair
Copy link
Contributor

Why do you need a key? This is for making TLS connections to consul, correct? Can’t you just add the ca file to the trusted root CAs in /etc/ssl?

@magiconair
Copy link
Contributor

And use an https URL for consul obviously

@jrasell
Copy link
Contributor Author

jrasell commented Dec 5, 2017

@magiconair yes that is an option and is what I currently do in my setups. I was merely adding this feature as detailed in the ticket #276

@magiconair
Copy link
Contributor

Ah, the cert and key are used for client cert authentication. The example uses the Consul server cert and that doesn't seem correct.

I can see several use cases:

  1. Use HTTPS:
    add registry.consul.scheme=https option

  2. Use custom CA:
    add registry.consul.tls.ca_path=/path/to/certs

  3. disable cert validation
    add registry.consul.tls.skip_verify = {true,false} to be (somewhat) consistent with the other options

  4. enable client cert authentication
    add registry.consul.tls.client_cert=/path/to/cert.pem and registry.consul.tls.client_key=/path/to/key.pem The key should be optional if both cert and key are in the same file. In this case both should point to the same file.

jrasell and others added 4 commits June 6, 2018 18:12
This change updates Fabio's configuration parameters to allow use
and specification of TLS certificates for HTTPS. In Consul setups
where full TLS is configured using CA private this allows Fabio
to work in a secure manner.

Closes fabiolb#276
jen20 added a commit to jen20/fabio that referenced this pull request Jun 6, 2018
@@ -168,6 +168,11 @@ func load(cmdline, environ, envprefix []string, props *properties.Properties) (c
f.StringVar(&cfg.Registry.Consul.KVPath, "registry.consul.kvpath", defaultConfig.Registry.Consul.KVPath, "consul KV path for manual overrides")
f.StringVar(&cfg.Registry.Consul.NoRouteHTMLPath, "registry.consul.noroutehtmlpath", defaultConfig.Registry.Consul.NoRouteHTMLPath, "consul KV path for HTML returned when no route is found")
f.StringVar(&cfg.Registry.Consul.TagPrefix, "registry.consul.tagprefix", defaultConfig.Registry.Consul.TagPrefix, "prefix for consul tags")
f.BoolVar(&cfg.Registry.Consul.EnableSSL, "registry.consul.enableSSL", defaultConfig.Registry.Consul.EnableSSL, "enable HTTPS communication with Consul")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uppercase words are not parsed by flag library. If you change it to lower case flag will parse it correctly. I mean - registry.consul.enableSSL change to registry.consul.enablessl
same for other added parametes

  • change to lowercase if property file

if cfg.EnableSSL {
cfg.Scheme = "https"

tls := &api.TLSConfig{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tls variable is shadowed here. Here should be
tls = api.TLSConfig{

@sev3ryn
Copy link
Contributor

sev3ryn commented Aug 2, 2018

Hi, I also faced a need for this functionality today.
But code in this PR have few issues and is not fully working - @jrasell see my comments on File changes tab.

BTW. @jrasell, if you abandoned this PR - I can pick it to implement changes that @magiconair requested

@vjeantet
Copy link

Hello, i need this functionality too.

Currently blocked because of lack of https to search consul. :(

How can we help ?

@eagle1981
Copy link

How about merge to next release? It's blocker feature for our deployment.

@tecnobrat
Copy link

@jrasell @sev3ryn is this abandoned? I also need this as well as its a blocker .. let me know if I can help, happy to try to refactor this PR.

@pires
Copy link
Contributor

pires commented Jun 1, 2019

This can be closed since #602 was merged, right?

@pschultz
Copy link
Member

pschultz commented Jun 3, 2019

Yes, thanks for the reminder.

@pschultz pschultz closed this Jun 3, 2019
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

Successfully merging this pull request may close these issues.

Support Consul TLS
10 participants