canonical / canonical/haproxy-operator

[haproxy-route] Match host header as domain, not as string

Open
#245 6 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
4
Forks
12
Avg merge
1d 8h
Merged PRs (30d)
22

Description

### Enhancement Proposal

Hi,

I've integrated `ingress-configurator` with `haproxy` using the `haproxy-route` interface and the following configuration:
```yaml
backend-addresses: 10.156.0.13
backend-ports: 80
hostname: test.example.com
paths: /development-jimm
```

This has given me the following HAProxy config:
```
frontend haproxy
mode http
bind [::]:80 v4v6
bind [::]:443 v4v6 ssl crt /var/lib/haproxy/certs
# Redirect HTTP to HTTPS
http-request redirect scheme https unless { ssl_fc }

acl acl_path_development-ingress-configurator path_beg -i /development-jimm
acl acl_host_development-ingress-configurator req.hdr(Host) -m str test.example.com
use_backend development-ingress-configurator if acl_path_development-ingress-configurator acl_host_development-ingress-configurator

default_backend default

backend development-ingress-configurator
balance leastconn
timeout server 60s
timeout connect 60s
timeout queue 60s

option httpchk
http-check send hdr Host test.example.com
server development-ingress-configurator_80_0 10.156.0.13:80
```

The workload this is connected to ([jimm](https://charmhub.io/juju-jimm-k8s)) exposes a Juju controller API. When I try to connect to it with the Juju CLI, host headers aren't sent by the Juju client and we see HAProxy logs indicating that the request falls through to the default backend:

```
haproxy~ default/ 0/-1/-1/-1/0 200 115 - - LR-- 1/1/0/0/0 0/0 "GET /development-jimm/api HTTP/1.1"
```

If I adjust the HAProxy `use_backend` configuration line to remove the `acl_host_development-ingress-configurator` directive, requests are correctly routed to the backend:

```
haproxy~ development-ingress-configurator/development-ingress-configurator_80_0 0/0/5/14/1029 101 2340 - - ---- 1/1/0/0/0 0/0 "GET /development-jimm/api HTTP/1.1"
```
---

Could we please update the possible configurations to allow for path-based routing without the requirement on host headers?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.