emissary-ingress / emissary

open source Kubernetes-native API gateway for microservices built on the Envoy Proxy
https://www.getambassador.io
Apache License 2.0
4.37k stars 687 forks source link

spec.host_redirect in Mapping does not work #5776

Open Vislor opened 2 months ago

Vislor commented 2 months ago

Describe the bug In a Mapping, whenever host_redirect is set to true, the mapping is not recognized and doesn't work. This happens no matter what redirect options are used (path, regex, prefix). We are not using label selectors to link the Mapping to a Host, we are using hostname and the hostname is not a wildcard (nor does it contain a wildcard). Mappings without host_redirect seem to work as expected (they are applied and associated with the proper Host).

To Reproduce Steps to reproduce the behavior:

  1. Create a mapping with a host_redirect, such as:
    apiVersion: ambassador.io/v3alpha1
    kind: Mapping
    metadata:
    name: test
    namespace: some-namespace
    spec:
    hostname: api.dev.local
    service: users-svc
    prefix: /swagger-dev/
    host_redirect: true
    prefix_redirect: /swagger
  2. Apply the mapping to the cluster
  3. In the diagnostics endpoint (http://localhost:8877/ambassador/v0/diag/) observe that the mapping has not been applied.
  4. Test the route, observe that a 404 is returned.

Expected behavior I expect the mapping to be applied and a 301 redirect to be returned.

Versions (please complete the following information):

cindymullins-dw commented 2 months ago

HI @Vislor, we do expect this to work. If the API version above is not a typo please try correcting it to 'getambassador', pls see example here.