Crash when adding request header `x-forwarded-proto`
See original GitHub issueDescribe the bug
I am trying to set the x-forwarded-proto
header to the upstream server using add_request_headers
config. When I access the URL, ambassador crashes.
Here’s my mapping:
---
apiVersion: v1
kind: Service
metadata:
name: myservice
labels:
app: myservice
annotations:
getambassador.io/config: |
---
apiVersion: ambassador/v0
kind: Mapping
name: myservice
prefix: /
host: myservice.mydomain.com
service: http://myservice.default:8088
add_request_headers:
x-forwarded-proto: "%PROTOCOL%"
spec:
type: NodePort
ports:
- name: myservice
port: 8088
targetPort: 8088
selector:
app: myservice
To Reproduce Steps to reproduce the behavior:
- Configure a route as described above
- Access the URL
- See error
Expected behavior
I expected the service to get the x-forwarded-proto
header, but instead ambassador crashes.
Versions (please complete the following information):
- Ambassador: 0.37.0
- Kubernetes environment: Azure Kubernetes Services (AKS)
- Version: v1.10.3
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:19 (9 by maintainers)
Top Results From Across the Web
Crash when adding request header x-forwarded-proto #680
Describe the bug I am trying to set the x-forwarded-proto header to the upstream server using add_request_headers config.
Read more >Support X-Forwarded-* HTTP headers alternates - Drupal
Issue category, Bug because this functionality is present in symfony, ... In Apache, this looks like: RequestHeader set X-Forwarded-Proto ...
Read more >Real life usage of the X-Forwarded-Host header?
X-Forwarded-Proto gives the protocol the client used to connect to the proxy ( http or https ); X-Forwarded-Host gives the content of the...
Read more >RequestHeader with Apache environment variable
The documentation says: When the RequestHeader directive is used with the add, append, or set argument, a fourth argument may be used to...
Read more >Configuring the BIG-IP system to insert the HTTP X-Forwarded ...
To create a custom HTTP profile that inserts an HTTP header named X-Forwarded-Proto: with a value of https into each request, perform the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The final decision of what the behavior of ambassador should be is, of course, up to your team. To me, however, I tend to think that anything that defies the user’s expectations is a defect. It is either: 1) a defect of implementation (A doesn’t behave as required), or 2) a defect of explanation (method A really does B).
Here, when one adds a header, I would expect the header to be set to that value, not that value plus something else, not a variant, but the value exactly as provided. Thus, that the resulting header value is “http, https” would be a defect by my standard because it is not literally “https”, as provided. I would have expected to need to do something like:
to get the behavior I am seeing (to concatenate what I want with what I have). Instead, I’m forced into the current behavior (a comma-separated list) without having an option for the behavior I want (a single value) where other implementations could do either.
If, as you say, “Ambassador seems to be doing the right thing,” maybe the naming is inaccurate because the behavior does not seem correct to me. If you discuss with your team at some point, please consider whether this is this how all the headers work, or if this is an undocumented special case, and whether this is the most flexible implementation for your users.
Thanks for your help, regardless.
In EA4, this crash no longer occurs, but the header is not modified either. An annotation like:
Will still forwarded from envoy as:
X-Forwarded-Proto: http
(when connecting to ambassador/envoy over http)