openbsd-httpd with gunicorn+uvicorn--远程协议错误:请求行非法



我的web部署设置在openBSD上,由前端的httpd和作为后端引擎的guicon+uvicon组成,通过unix套接字连接。

设置是有效的,从这个意义上说,来自httpd的请求通过unix套接字转发到gunicorn。但是,gunicorn/uvicorn无法理解传入的http请求。错误堆栈

[2021-11-22 22:52:17 +0530] [1631] [WARNING] Invalid HTTP request received.
Traceback (most recent call last):
File "/home/shared/Builds/Python-3.10.0/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 136, in handle_events
event = self.conn.next_event()
File "/home/shared/Builds/Python-3.10.0/lib/python3.10/site-packages/h11/_connection.py", line 443, in next_event
exc._reraise_as_remote_protocol_error()
File "/home/shared/Builds/Python-3.10.0/lib/python3.10/site-packages/h11/_util.py", line 76, in _reraise_as_remote_protocol_error
raise self
File "/home/shared/Builds/Python-3.10.0/lib/python3.10/site-packages/h11/_connection.py", line 425, in next_event
event = self._extract_next_receive_event()
File "/home/shared/Builds/Python-3.10.0/lib/python3.10/site-packages/h11/_connection.py", line 367, in _extract_next_receive_event
event = self._reader(self._receive_buffer)
File "/home/shared/Builds/Python-3.10.0/lib/python3.10/site-packages/h11/_readers.py", line 68, in maybe_read_from_IDLE_client
raise LocalProtocolError("illegal request line")
h11._util.RemoteProtocolError: illegal request line

我不确定非法请求线路的潜在原因是什么。

httpd不支持http代理。它支持为静态文件以及FastCGI提供服务。以及错误消息,指示您的httpd尝试使用FastCGI与gunicorn通信。

因此,如果您坚持使用httpd,请找到一种使用FastCGI服务器而不是WSGI(gunicorn(运行应用程序的方法。许多年前,flup是一个流行的选择。

或者,只使用Nginx而不是httpd

最新更新