xuhuigithub opened a new issue #2666:
URL: https://github.com/apache/apisix/issues/2666


   ### Issue description
     
使用HTTP1.0协议不携带`Host`头部时apisix会返回[400状态码](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Host),在HTTP1.0的标准定义中Host头部是可以缺失的[(定义中没有提到Host头部)](https://tools.ietf.org/html/rfc1945#section-10),apisix
 
因为配置文件后端代理默认使用的http1.1协议的问题,在装配负载均衡请求时,[也使用了http的Host头部,链接是apisix的nginx配置模板](https://github.com/apache/apisix/blob/53a8f5a2ed85e4bd00e5889e7d1ab7f7e3228d98/apisix/cli/ngx_tpl.lua#L382)。在负载均衡HTTP1.0到HTTP1.1之间的转换,缺失了Host头部缺失的判断逻辑。
   
   ### Environment
   
   * apisix version (cmd: `apisix version`): 1.4
   * OS: Centos 7.2
   
   ### Minimal test code / Steps to reproduce the issue
   1. curl -XGET -I -H 'Host:' -0 http://apisix1:9000/xx2
   
   ### What's the actual result? (including assertion message & call stack if 
applicable)
   ```bash
   (base) xuhui@g:~$ curl -XGET -I -H 'Host:' -0 http://apisix1:9000/xx2
   HTTP/1.1 400 
   Connection: close
   Date: Mon, 09 Nov 2020 07:03:54 GMT
   Server: APISIX web server
   ```
   access日志打出:"GET /xx2 HTTP/1.0" 400 0 0.001 "-" "curl/7.65.3" "-" 
127.0.0.1:8088 400 0.001
   
   
   ### What's the expected result?
   ```bash
   curl -XGET -I -H 'Host:' -0 http://apisix1:9000/xx2
   ````
   
返回200,且Host头部不应该缺失,而是转换为后端名称。详情的话可以看一下HTTP1.1的[RFC](https://tools.ietf.org/html/rfc7230#section-5.4)。


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to