When nginx is forwarding, the content of the header with '_' is lost (forwarding)

Forwarding: https://blog.csdn.net/Nazir2513/article/details/70889319

The APP that passed the test in the test environment was going to switch to the online environment for the final test today, but found an error. Looking at the log, it is found that the header content in the http request sent by the APP is lost. Then the code has not changed, how can the header information be lost for no reason?
So I thought that the difference between the two environments is that the online proxy forwarding is done through nginx. Could it be the ghost of nginx? So I searched for "nginx request header is missing", and sure enough, this is the problem. nginx restricts the underlined header information. Finding the problem is equivalent to more than half of the completion. The solution is always more difficult. So decided to record it.
- Method 1: No underscores
Since nginx does not support underscores, it doesn't matter, just don't need underscores. For example, the original "app_version" can be changed to "app-version". (It is no wonder that the name of the general header is spliced ​​with '-', such as "User-Agent")
- Method 2: When
the header of the default request of nginx contains '_', it will be automatically ignored. .
The solution is: add the following configuration to the http section in the nginx.conf configuration file in nginx:
underscores_in_headers on; (default underscores_in_headers is off)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326225647&siteId=291194637