0

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'

gthread如果我使用 Gunicorn工人类启动上述烧瓶应用程序。

gunicorn -k gthread --log-level debug hello:app

每当客户端发送 HTTPS 请求curl -vv https://localhost:8000时,Gunicorn 服务器都会派生一个工作人员来处理该请求,但它确实知道如何处理它。

在客户端,它将等待握手进行。

curl -vv https://localhost:8000
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8000 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8000 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):

有没有办法将 Gunicorn 服务器配置为只接受 HTTP 请求?对于 HTTPS 等其他协议,只需终止连接即可,而无需为此浪费工作人员。

4

0 回答 0