jcmoraisjr / haproxy-ingress

HAProxy Ingress
https://haproxy-ingress.github.io
Apache License 2.0
1.03k stars 269 forks source link

Longest matching path does not match when host name is empty #1156

Open pmint93 opened 1 month ago

pmint93 commented 1 month ago

Description of the problem

Rules that has longest path but without host field are put into default backend map, which has lowest precedence, so it won't match if it overlap with other rules that has host field specified

Expected behavior

Traffic of example.com/foo should goes to foo-service As guided in kubernetes ingress: precedence should be given first to the longest matching path

Steps to reproduce the problem

  1. Create 2 ingresses as bellow:

To route all traffic with prefix /foo to foo-service

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: foo-ingress
spec:
  ingressClassName: haproxy
  rules:
  - http:
      paths:
      - path: /foo
        pathType: Prefix
        backend:
          service:
            name: foo-service
            port:
              number: 80

To route traffic of example.com/ to baz-service

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: baz-ingress
spec:
  ingressClassName: haproxy
  rules:
  - host: example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: baz-service
            port:
              number: 80
  1. Go to http://example.com/foo to see that request are unexpectedly route into baz-service

Environment information

HAProxy Ingress version: v0.14.6

github-actions[bot] commented 2 weeks ago

This issue got stale and will be closed in 7 days.