0

使用PHP-FPM + Nginx 运行PHP获取不到自定义HEADER

tiffany created at6 years ago view count: 2746

使用PHP-FPM + Nginx 运行PHP获取不到客户端传的自定义HEADER, 再抓包工具里面有抓到header。 但是PHP里面却获取不到。

GET /api/v1/users/order/list?page=1&pre_page=20&status=1%2C5&type=1 HTTP/1.1^M
Host: 127.0.0.1^M
Accept: */*^M
system_version: 10.3.1^M
app_version: 1.0.0^M
X-REQUESTED-WITH: 1^M
Accept-Language: zh-cn^M
system_platform: iOS^M
Accept-Encoding: gzip^M
Content-Type: application/json^M
User-Agent:  (iPhone; iOS 10.3.1; Scale/3.00)^M
Connection: keep-alive^M
report
回复
0

用getallheaders试试看。

6 years ago 回复
0

试了下使用Apache用apache_request_headers是能获取到的。

6 years ago 回复
0

header里面不能用下划线,高版本的Nginx应该不会传给PHP-FPM, 用-代替

header命名是有规范的。 自定义的最好使用X-User-Type这种以X开始的header,与Cookie这些http协议里面的header做区分。

自定义header 查看下 https://stackoverflow.com/questions/3561381/custom-http-headers-naming-conventions

6 years ago 回复

Recent search keywords