kubernetes-ingress icon indicating copy to clipboard operation
kubernetes-ingress copied to clipboard

"request-redirect" annotation always redirects to http

Open fgmpe opened this issue 1 year ago • 4 comments

I have Ingress with request-redirect annotation:

## ...
annotations:
    haproxy.org/request-redirect: www.example.org
spec:
  rules:
    - host: example.com
## ...

When I send request for https://example.org, I expect response with header Location: https://www.example.org, but in reality I get Location: http://www.example.org

HAProxy configuration line is always rendered with hardcoded http protocol.

frontend https
  ## ...
  http-request redirect location http://www.example.org%[capture.req.uri] code 302 if { var(txn.path_match) -m dom 000.... } 
  ## ...

It would be great if this could be customized with new annotation the same way as request-redirect-code allows to customize the redirect code, or directly in existing annotation value:

annotations:
   ## proposal 1 - new annotation for protocol override
    haproxy.org/request-redirect-protocol: https

   ## proposal 2 - existing annotation with optional protocol
    haproxy.org/request-redirect: https://www.example.org

fgmpe avatar Feb 13 '24 15:02 fgmpe

It looks like it's already prepared here. But I can't see how to set the value of r.SSLRequest with Ingress annotation.

fgmpe avatar Feb 13 '24 15:02 fgmpe

Hi @fgmpe , Your second idea seems to be the best as it's more direct. I'll check if the team is ok with that.

ivanmatmati avatar Feb 19 '24 10:02 ivanmatmati