Get the App
SLTechnology News&Howtos  ›  Servers  › 

What if the & quot;_" information is lost in the header header when the Nginx agent

Shulou Source: shulou.com Published: 2022-06-01 16:10:00 11月13日 Update

The purpose of this article is to share with you what to do when Nginx agents lose information with "_" in the header of header. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Preface

When developing a gateway project, the signature sign_key information is put into the request header header when the request is made, and then taken out from the header when the request is received. It is possible to debug locally, but after being launched, it is found that it cannot be obtained through the Nginx proxy.

Location / {proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Nginx-Proxy true; add_header Proxy-Node $upstream_addr; add_header Proxy-Status $upstream_status; proxy_http_version 1.1; proxy_pass http://tianusa;}

Later, it was found that the reason is that Nginx has restrictions on header, and underscores (_) are not supported.

Solution:

1. No need to underline

Change the underscore _ to something else, such as sign_key to sign-key

two。 Lift the restrictions on Nginx from the root

Nginx automatically ignores'_ 'when it contains' _'in the header of the default request.

The solution is to add the following configuration to the http section of the nginx.conf configuration file in nginx:

Underscores_in_headers on; (default underscores_in_headers is off) Thank you for reading! This is the end of the article on "Nginx Agent with header in the head" _ "what if the information is lost". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Information agent underline what to do medium band content method more article configuration restriction good practical no Chinese preface reason file article basic Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Linux Xiaomi Shulou Tech Info vpn