diff --git a/consul/base.py b/consul/base.py index ee6ab254..3a717aff 100755 --- a/consul/base.py +++ b/consul/base.py @@ -313,13 +313,19 @@ def __init__( if os.getenv('CONSUL_HTTP_ADDR'): try: host, port = os.getenv('CONSUL_HTTP_ADDR').split(':') + scheme = 'http' except ValueError: - raise ConsulException('CONSUL_HTTP_ADDR (%s) invalid, ' - 'does not match :' - % os.getenv('CONSUL_HTTP_ADDR')) + try: + scheme, host, port = os.getenv('CONSUL_HTTP_ADDR').split(':') + host = host.lstrip('//') + except ValueError: + raise ConsulException('CONSUL_HTTP_ADDR (%s) invalid, ' + 'does not match : or ' + '::' + % os.getenv('CONSUL_HTTP_ADDR')) use_ssl = os.getenv('CONSUL_HTTP_SSL') - if use_ssl is not None: - scheme = 'https' if use_ssl == 'true' else 'http' + if use_ssl == 'true': + scheme = 'https' if os.getenv('CONSUL_HTTP_SSL_VERIFY') is not None: verify = os.getenv('CONSUL_HTTP_SSL_VERIFY') == 'true'