首页 > 解决方案 > Python 服务器的问题

问题描述

我正在为我的一个移动应用程序的后端创建一个 Python 服务器。我正在为 python 服务器使用 http.server.BaseHTTPRequestHandler 类。我还使用 Nginx 作为反向代理,将请求重新路由到我的 python 服务器。所有这些都在 DigitalOcean Ubuntu 机器上。我为 python 服务器创建了 systemd 服务文件来执行脚本。通常当我重新启动服务时,它会运行一两天完全正常,但随后我得到一个 504 Bad Gateway。在查看我的 python 服务器的日志时,我得到了这个:

-[31/Oct/2021 01:07:32] "GET / HTTP/1.0" 400 -
-[31/Oct/2021 01:07:38] "GET / HTTP/1.0" 400 -
-[31/Oct/2021 01:07:38] "GET /nmaplowercheck1635642271 HTTP/1.1" 400 -
-[31/Oct/2021 01:07:38] "POST /sdk HTTP/1.1" 400 -
-[31/Oct/2021 01:07:38] "GET /evox/about HTTP/1.1" 400 -
-[31/Oct/2021 01:07:38] "GET /HNAP1 HTTP/1.1" 400 -
-[31/Oct/2021 01:07:39] "GET / HTTP/1.0" 400 -
-[31/Oct/2021 01:07:39] "GET / HTTP/1.1" 400 -
-[31/Oct/2021 01:08:02] "GET / HTTP/1.1" 400 -
-[31/Oct/2021 01:08:03] "GET /favicon.ico HTTP/1.1" 400 -
-[31/Oct/2021 01:55:46] "GET /config/getuser?index=0 HTTP/1.1" 400 -
-[31/Oct/2021 02:45:56] "GET / HTTP/1.1" 400 -
-[31/Oct/2021 03:09:50] code 400, message Bad request syntax ('\x05\x01\x00')
-[31/Oct/2021 04:14:39] "GET /config/getuser?index=0 HTTP/1.1" 400 -
-[31/Oct/2021 05:33:06] "GET / HTTP/1.1" 400 -
-[31/Oct/2021 05:33:23] "POST /api/jsonws/invoke HTTP/1.1" 400 -
-[31/Oct/2021 09:05:12] code 400, message Bad request version ('»_ô\x00\x01<Ì\x14Ì\x13Ì\x15À0>
-[31/Oct/2021 09:49:57] "GET / HTTP/1.1" 400 -

Nginx 错误日志给了我这个:upstream timed out (110: Connection timed out) while connection to upstream

这是 Nginx 还是 python 的问题?

标签: pythonnginxsystemdbasehttpserver

解决方案


推荐阅读