我对nginx配置有疑问。我向nginx发送了一个请求,其中包含我知道无效的标头,并希望使用nginx修改该标头以使其有效。
请求:
curl -X POST -d "data=string" -H "Host:192.168.99.100" -H "Connection: close" -H "Accept-Encoding: identity" -H "Content-Type: application/x-www-form-urlencoded" -H "Content-Length: 22\r\n" -i http://192.168.99.100/protocol_1.2
注意Content-Length:22 \ r \ n(CRLF)
然后在error.log中,使用loglevel INFO我得到
[info] 5#0: *1 client sent invalid "Content-Length" hader while reading client request headers, client: 192.168.99.1, server: example.org,request: "POST /protocol_1.2 HTTP/1.1", host: "192.168.99.100"
不幸的是我无法修改请求的来源,所以想要在nginx中修改它。有没有办法在nginx处理进程之前修改传入的标题?
我的网站启用非常简单:
server {
listen 80;
server_name example.org;
charset utf-8;
error_log /var/log/nginx/error.log info;
ignore_invalid_headers on;
location /static {
alias /usr/src/app/static;
}
location / {
proxy_pass http://music:8010;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
谢谢, 凯文