healthcheck with custom host header requires exact case
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 43
Description
### `consul version` for both Client and Server
Client: 1.0.1
Server: 1.0.1
### `consul info` for both Client and Server
Client:
```
agent:
check_monitors = 0
check_ttls = 0
checks = 8
services = 9
build:
prerelease =
revision = 9564c29
version = 1.0.1
consul:
known_servers = 3
server = false
runtime:
arch = amd64
cpu_count = 16
goroutines = 50
max_procs = 16
os = linux
version = go1.9.2
serf_lan:
coordinate_resets = 0
encrypted = true
event_queue = 0
event_time = 5
failed = 0
health_score = 0
intent_queue = 0
left = 0
member_time = 385
members = 59
query_queue = 0
query_time = 1
```
Server:
```
agent:
check_monitors = 0
check_ttls = 0
checks = 0
services = 0
build:
prerelease =
revision = 9564c29
version = 1.0.1
consul:
bootstrap = false
known_datacenters = 1
leader = false
leader_addr = 172.30.226.112:8300
server = true
raft:
applied_index = 1062465
commit_index = 1062465
fsm_pending = 0
last_contact = 13.199667ms
last_log_index = 1062465
last_log_term = 3
last_snapshot_index = 1057345
last_snapshot_term = 3
latest_configuration = [{Suffrage:Voter ID:a03b6482-2922-7f8c-50c2-3b9f9afc2a15 Address:172.30.201.196:8300} {Suffrage:Voter ID:39c7072b-ade1-cc48-16f8-698febbf7a68 Address:172.30.189.75:8300} {Suffrage:Voter ID:5c825eac-110b-7e4d-4795-69f03b617a43 Address:172.30.226.112:8300}]
latest_configuration_index = 1
num_peers = 2
protocol_version = 3
protocol_version_max = 3
protocol_version_min = 0
snapshot_version_max = 1
snapshot_version_min = 0
state = Follower
term = 3
runtime:
arch = amd64
cpu_count = 1
goroutines = 229
max_procs = 1
os = linux
version = go1.9.2
serf_lan:
coordinate_resets = 0
encrypted = true
event_queue = 0
event_time = 5
failed = 0
health_score = 0
intent_queue = 0
left = 0
member_time = 385
members = 59
query_queue = 0
query_time = 1
serf_wan:
coordinate_resets = 0
encrypted = true
event_queue = 0
event_time = 1
failed = 0
health_score = 0
intent_queue = 0
left = 0
member_time = 4
members = 3
query_queue = 0
query_time = 1
```
### Operating system and Environment details
Debian jessie on the clients on aws
Debian strech on the server on aws
### Description of the Issue (and unexpected/desired result)
When registering a service with this payload:
```
{
"Id":"live--eu-central-1a--ana--i-02fdce3352eed27ff:ana-testing",
"Name":"ana-testing",
"Port":80,
"Check":{
"DeregisterCriticalServiceAfter": "1h",
"http":"http://172.30.149.118:80/healthcheck/?critical=true",
"header": {"host":["ana-testing.internal"],"x-forwarded-proto":["https"]},
"interval": "5s",
"timeout": "4s"
}
}
```
the service is registered successful, but the healthcheck fails to send the correct host, it sends the IP as `Host` header and we have a "extra" lower case host entry:
```
GET /healthcheck/?critical=true HTTP/1.1
Host: 172.30.149.118:80
User-Agent: Consul Health Check
Accept: text/plain, text/*, */*
X-Forwarded-Proto: https
host: ana-testing.internal
```
Checking the consul code, i could see that it only checks for the `Host` header, exact case.
RFC 7230 [states](https://tools.ietf.org/html/rfc7230#section-3.2): "_Each header field consists of a case-insensitive field name followed by a colon (":"), optional leading whitespace, the field value, and optional trailing whitespace._"
So while it uses `Host` in all examples, the RFC do not enforce that case, so consul should also accept the lower case version to avoid confusions and be friendly to users typing the lower case version, instead of silently testing a wrong "virtual host".
If we do the above request, with the "correct" `Host` header case, both headers are registered and there is only one `Host` header, so fixing the case sensitive check is all that is needed.
Contributor guide
Assessment
This issue has not been assessed yet.