POC: Setting upstream vhost for nginx.
In the current k8 ingress there's no way to control "Host" header sent to upstream server; it's always the configured vhost. It's desirable to support custom Host header when proxying for a number of cases. One such case is forwarding to an Service that points to an external host that expect a host paramater (like AWS S3 buckets). There's a number of others. By default nginx set Host to the upstreams domain name (and not the one passed in) like K8 always forces. This provided an escape hatch to this behavior.
This commit is contained in:
parent
7eb2b81fd3
commit
2120aab66c
4 changed files with 54 additions and 0 deletions
|
|
@ -698,7 +698,13 @@ stream {
|
|||
client_body_buffer_size {{ $location.ClientBodyBufferSize }};
|
||||
{{ end }}
|
||||
|
||||
{{/* By default use vhost as Host to upstream, but allow overrides */}}
|
||||
{{ if not (empty $location.UpstreamVhost) }}
|
||||
proxy_set_header Host "{{ $location.UpstreamVhost }}";
|
||||
{{ else }}
|
||||
proxy_set_header Host $best_http_host;
|
||||
{{ end }}
|
||||
|
||||
|
||||
# Pass the extracted client certificate to the backend
|
||||
{{ if not (empty $server.CertificateAuth.CAFileName) }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue