pomerium/config
Kenneth Jenkins 79d5657742
envoy: set explicit hostname on cluster endpoints (#5018)
Envoy has an option 'auto_host_rewrite' that rewrites the Host header of
an incoming request to match the upstream domain that the proxied
request is sent to. Pomerium sets the 'auto_host_rewrite' option for all
Pomerium routes that do not set one of the "Host Rewrite options" (see
https://www.pomerium.com/docs/reference/routes/headers#host-rewrite-options).

When Envoy rewrites the Host header, it does not include the upstream
port, even when it is a non-standard port for the scheme (i.e. a port
other than 80 for http or a port other than 443 for https).

I think this behavior does not conform to RFC 9110. The nearest thing I
can find in the text is this statement about http and https URIs:
"If the port is equal to the default port for a scheme, the normal form
is to omit the port subcomponent."
(from https://datatracker.ietf.org/doc/html/rfc9110#section-4.2.3)

I take this to mean that the port should be specified in other cases.

There is a work-around: we can set an explicit hostname on each cluster
endpoint. Let's set this hostname based on the 'to' URL(s) from the
Pomerium route.

This should change the current behavior in two cases:

 - When a route has a 'to' URL with a port number, this port number will
   now be included in the Host header in the requests made by Pomerium.

 - When a route has a 'to' URL with 'localhost' or an IP address as the
   host, Pomerium will now rewrite the Host header to match the 'to'
   URL.

There should be no change in behavior for routes where one of the "Host
Rewrite options" is set.
2024-03-14 14:00:32 -07:00
..
envoyconfig envoy: set explicit hostname on cluster endpoints (#5018) 2024-03-14 14:00:32 -07:00
testdata config: additional kubernetes token source support (#1200) 2020-08-04 09:40:51 -04:00
autocert.go core/ci: update linting (#4844) 2023-12-14 09:07:54 -08:00
autocert_test.go config: update logic for checking overlapping certificates (#4216) 2023-06-01 09:30:46 -06:00
codec_type.go config: allow specifying auto codec type in all-in-one mode (#2846) 2021-12-22 12:34:58 -07:00
codec_type_test.go config: default to http2 (#3660) 2022-10-12 14:46:06 -06:00
config.go config: no longer stub out HPKE public key fetch (#4853) 2023-12-12 09:57:58 -08:00
config_source.go config: remove deprecated client_ca option (#4918) 2024-01-30 14:12:23 -08:00
config_source_test.go core/config: refactor file watcher (#4702) 2023-11-03 15:53:20 -06:00
constants.go core/config: implement direct response (#4960) 2024-02-15 14:33:56 -07:00
crypt.go cryptutil: always use kek public id, add x509 support (#2066) 2021-04-07 09:44:36 -07:00
custom.go core/config: add support for maps in environments (#4717) 2023-11-08 16:27:08 -07:00
custom_test.go all: remove unused handler code (#2439) 2021-08-16 16:04:39 -04:00
doc.go *: remove import path comments (#545) 2020-03-16 10:13:47 -07:00
from.go config: add support for wildcard from addresses (#4131) 2023-04-25 13:34:38 -06:00
from_test.go config: add support for wildcard from addresses (#4131) 2023-04-25 13:34:38 -06:00
helpers.go core/redis: remove redis (#4768) 2023-11-28 13:14:36 -07:00
helpers_test.go databroker: rename cache service (#1790) 2021-01-21 08:41:22 -07:00
http.go use tlsClientConfig instead of custom dialer (#3830) 2022-12-27 09:55:36 -07:00
http_test.go httputil/reproxy: fix policy transport (#3322) 2022-05-04 18:32:36 -06:00
identity.go move directory providers (#3633) 2022-11-03 11:33:56 -06:00
layered.go core/ci: update linting (#4844) 2023-12-14 09:07:54 -08:00
layered_test.go core/config: refactor change dispatcher (#4657) 2023-11-01 13:52:23 -06:00
log.go core/config: remove debug option, always use json logs (#4857) 2023-12-15 11:29:05 -07:00
log_level.go config: validate log levels (#4367) 2023-07-17 16:41:48 -06:00
metrics.go config: remove source, remove deadcode, fix linting issues (#4118) 2023-04-21 17:25:11 -06:00
metrics_test.go config: remove source, remove deadcode, fix linting issues (#4118) 2023-04-21 17:25:11 -06:00
mtls.go config: support client certificate SAN match (#4453) 2023-08-11 13:27:12 -07:00
mtls_test.go core/ci: update linting (#4844) 2023-12-14 09:07:54 -08:00
options.go config: remove deprecated client_ca option (#4918) 2024-01-30 14:12:23 -08:00
options_check.go config: remove deprecated client_ca option (#4918) 2024-01-30 14:12:23 -08:00
options_test.go config: remove deprecated client_ca option (#4918) 2024-01-30 14:12:23 -08:00
policy.go core/config: implement direct response (#4960) 2024-02-15 14:33:56 -07:00
policy_ppl.go authorize: omit client cert rule when not needed (#4386) 2023-07-24 15:27:57 -07:00
policy_ppl_test.go core/opa: update for rego 1.0 (#4895) 2024-01-16 09:43:35 -07:00
policy_test.go core/redis: remove redis (#4768) 2023-11-28 13:14:36 -07:00
session.go core/config: remove cookie secure option (#4907) 2024-01-12 13:28:14 -07:00
session_test.go config: allow blank identity providers when loading sessions for service account support (#3709) 2022-10-27 08:32:06 -06:00
trace.go config: remove source, remove deadcode, fix linting issues (#4118) 2023-04-21 17:25:11 -06:00
trace_test.go log context (#2107) 2021-04-22 10:58:13 -04:00
validate.go config: add cookie_same_site option (#4148) 2023-05-03 14:36:42 -06:00