Issue when using "add" with X-Forwarded-Proto header #2529
-
After applying NGF, I encountered a CORS issue. When checking the configuration in the NGINX container, I found a difference compared to my previous NGINX setup.
Previously, I was using the above setting to add the scheme information to the X-Forwarded-Proto header and forward it to the backend. However, I noticed that this part was missing from the current configuration. I suspect that the CORS issue occurred because the protocol was not properly forwarded to the backend. To solve this, I tried adding the header using the RequestHeaderModifier filter, and the problem was resolved (I noticed that using the $ character to directly use variables was not possible).
However, I don't feel comfortable using a hardcoded string, so I tried modifying the configuration slightly. When I used the add tag, it automatically created a ${} block and appended the protocol followed by the tag I set.
I want to know how I can configure it so that only ${x_forwarded_proto_header_var} remains, without adding any extra strings or values. I thought I could use an empty string with add, but it turned out to be an invalid value, so it was not applied. How can I achieve this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@utopiandreams we recently added the So we now add the following headers by default to all location blocks:
These changes are in the |
Beta Was this translation helpful? Give feedback.
@utopiandreams we recently added the
X-Forwarded-Proto: $scheme
header to the base nginx configuration: https://github.com/nginxinc/nginx-gateway-fabric/blob/1241d101314b535192b89e1114965c0a52064388/internal/mode/static/nginx/config/servers.go#L49.So we now add the following headers by default to all location blocks: