由于80端口需要root用戶才能使用,所以tomcat都是root用戶管理的,為了安全起見昨天安裝了一個(gè)nginx作為反向代理,tomcat改為8080端口。但測試發(fā)現(xiàn)有幾個(gè)接口一直報(bào)錯(cuò),幾個(gè)HTTP頭取不到值,比對(duì)其他請(qǐng)求發(fā)現(xiàn)是包含了下劃線。在百度和stackoverflow上查找問題發(fā)現(xiàn),要求配置一下nginx,支持HTTP Header name支持下劃線:
Syntax: | underscores_in_headers on | off ;
|
---|
Default: | underscores_in_headers off; |
---|
Context: | http , server
|
---|
Enables or disables the use of underscores in client request header fields. When the use of underscores is disabled, request header fields whose names contain underscores are marked as invalid and become subject to the ignore_invalid_headers directive.
If the directive is specified on the server level, its value is only used if a server is a default one. The value specified also applies to all virtual servers listening on the same address and port.
但是nginx為什么要加這個(gè)配置呢,查找資料有的說HTTP Header name不能包含下劃線。
翻了翻HTTP RFC,好像沒有這個(gè)要求。
Each header field consists of a case-insensitive field name followed by a colon (":"), optional leading whitespace, the field value, and optional trailing whitespace.