代码之家  ›  专栏  ›  技术社区  ›  Andre

为什么烧瓶会产生错误连接重置?

  •  0
  • Andre  · 技术社区  · 7 年前

    服务器上的Python代码:

    from flask import *
    from flask_cors import CORS
    
    app = Flask(__name__)
    CORS(app)
    
    @app.route('/')
    def index():
        return Response('Index')
    if __name__ == '__main__':
        app.run(debug=True, host='***.***.***.***', port=80, ssl_context=('certificates/cert.pem', 'certificates/key.pem'))
    

    证书和钥匙。pem文件是通过以下方式生成的:

    openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
    

    还有教程 here 它们将很快使用certbot进行更新。

    我也试着去问问 curl 输出使用: curl -i https://***.***.***.***:80 -k >> CurlOutput.txt 但文件是空的。

    有没有办法在certbot的证书准备好之前保留当前证书,并解决连接问题?

    0 回复  |  直到 7 年前
        1
  •  1
  •   Erik Dz    5 年前

    您正在使用端口80为SSL提供服务。使用发送至HTTPS的端口443。我也犯了同样的错误,这帮我解决了。

    因此,只需将最后一行更改为:

    if __name__ == '__main__':
    
        app.run(debug=True, host='***.***.***.***', port=443, ssl_context=('certificates/cert.pem', 'certificates/key.pem'))
    
    推荐文章