host_redirect cleans up the request port when port_redirect is not specified
#17.318 aperta il 13 lug 2021
Metriche repository
- Star
- (27.997 star)
- Metriche merge PR
- (Merge medio 8g) (378 PR mergiate in 30 g)
Descrizione
Description: When host_redirect is specified but port_redirect is not, port is not preserved in the response. Envoy cleans up the port in the response(https://github.com/envoyproxy/envoy/blob/main/source/common/router/config_impl.cc#L791). Envoy should preserve the port in the request if port_redirect is not specified or it should be clarified in the doc(https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-redirectaction) that the port will be cleaned up if port_redirect is not specified.
Repro steps:
- Configure a route to do host_redirect in a listener that listens to a port other than 80 or 443
- Send a request to the route
curl -v --resolve redirect-test:10080:127.0.0.1 http://redirect-test:10080
* Added redirect-test:10080:127.0.0.1 to DNS cache
* Rebuilt URL to: http://redirect-test:10080/
* Hostname redirect-test was found in DNS cache
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to redirect-test (127.0.0.1) port 10080 (#0)
> GET / HTTP/1.1
> Host: redirect-test:10080
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< location: http://redirect-test.mydomain.com/
< date: Tue, 13 Jul 2021 17:33:32 GMT
< server: envoy
< content-length: 0
<
* Curl_http_done: called premature == 0
* Connection #0 to host redirect-test left intact
Config:
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 10080
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: backend
domains:
- "*"
routes:
- match:
prefix: "/"
redirect:
host_redirect: "redirect-test.mydomain.com"
http_filters:
- name: envoy.router
config: {}