fabiolb / fabio

Consul Load-Balancing made simple
https://fabiolb.net
MIT License
7.25k stars 621 forks source link

Strip port in host header? #834

Open resmo opened 3 years ago

resmo commented 3 years ago

First, sorry for asking user questions here but I couldn't find another way to ask this.

Setup

Running Nomad and Consul, fabio as system job on every client node as well as dnsmasq with config

server=/consul/127.0.0.1#8600
# client nodes own private range IP
address=/.service/10.23.12.133 

That means there is wildcard for .service to resolve to local IP.

$ dig myapp.service +short
10.23.12.133

Fabio is listening on 10.23.12.133:9999

Having a service registered myapp.service -> 10.1.2.3:20000

When I use curl (and other http clients from other services) like

$ curl -I http://myapp.service:9999
HTTP/1.1 404 Not Found
Date: Thu, 17 Jun 2021 13:19:30 GMT

it fails with 404

But when I do

$ curl -I --header "Host: myapp.service" http://10.23.12.133:9999
HTTP/1.1 302 Found

The difference is the host header having the port in the first sample

> Host: myapp.service:9999

This means, I need to register the service as urlprefix-myapp.service:9999/. This works, however, it kind of feels like redundant.

Is there a way to tell fabio to ignore the port in the host header? ignore-http-header-port=true?