Recently I have migrated an application which was deployed in Apache Webserver to Nginx. After the migration, the application stopped working. On troubleshooting I found that some of the requests were getting cancelled because of missing headers.
We were using Google Single Sign-On in the application and Google passes some headers with underscore symbol. As per HTTP standards, headers with underscore are perfectly valid. But by default Nginx ignores the headers with underscore.
To enable Nginx to accept headers with underscore, we need to add the following parameter in the server block of Nginx configuration.
underscores_in_headers on;
After adding this configuration parameter, validate and reload the configuration by using the following command.
nginx -t
service nginx reload
This will solve the issue. I hope this tip is useful.
Thats exactly i was searching for!! Thanks man
Glad to know that the article is useful.
Thank you! This was an infuriatingly stupid waste of time. The RFQ is clear, so this is a brain dead and irresponsible default.
According to the RFC, “_” is legitimate token (https://www.rfc-editor.org/rfc/rfc2616#page-31) text, and the header field-name (https://www.rfc-editor.org/rfc/rfc2616#page-32) labels are supposed to allow tokens. So, this would seem to be a time wasting default in NGINX that angers me to no end. And would you trust http://nginx.org/en/docs/http/ngx_http_core_module.html#ignore_invalid_headers now? I’ve turned that off.
token = 1*
separators = “(” | “)” | “” | “@”
| “,” | “;” | “:” | “\” |
| “/” | “[” | “]” | “?” | “=”
| “{” | “}” | SP | HT
message-header = field-name “:” [ field-value ]
field-name = token
field-value = *( field-content | LWS )
field-content =