我的web部署设置在openBSD上,由前端的httpd和后端的guicorn + uvicorn引擎组成,通过unix socket连接。
设置是有效的,因为来自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我不确定非法请求行的潜在原因是什么。
发布于 2021-11-22 18:24:51
httpd不支持http代理。它支持为静态文件和FastCGI提供服务。和错误消息,指示您的httpd尝试使用FastCGI与gunicorn通信。
因此,如果你坚持使用httpd,那么就找到一种方法来使用FastCGI服务器而不是WSGI (gunicorn)来运行你的应用程序。许多年前,flup是一个流行的选择。
或者,只使用Nginx而不是httpd。
https://stackoverflow.com/questions/70070128
复制相似问题