拒绝与 Apache2 上的 Flask WSGI 应用程序建立连接

拒绝与 Apache2 上的 Flask WSGI 应用程序建立连接

我正在尝试在 Apache2 服务器上运行 Flask API,但收到 net::ERR_CONNECTION_REFUSED

由于我在另一台服务器上运行 flask API,因此我在主 apache 服务器上以以下方式使用代理反向:

Listen 5001
<VirtualHost *:5001>
        ServerAdmin [email protected]
        ServerName myapiserver.io
        SSLEngine on
        SSLOptions +ExportCertData
        SSLCertificateFile /etc/ssl/myapiserver/STAR_myapiserver_io.crt
        SSLCertificateKeyFile /etc/ssl/private/myapiserver/myapiserver.io.key
        SSLCertificateChainFile /etc/ssl/myapiserver/SectigoRSADomainValidationSecureServerCA.crt
        SSLProxyEngine on
        ProxyPass / https://10.0.10.242:5001/
        ProxyPassReverse / https://10.0.10.242:5001/
        ProxyPreserveHost On
</VirtualHost>

我的myapiserver配置:

Listen 5001
<VirtualHost *:5001>
     ServerName myapiserver.io
     SSLEngine on
     SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
     SSLCertificateFile /etc/ssl/private/myapiserver/STAR_myapiserver_io.crt
     SSLCertificateKeyFile /etc/ssl/myapiserver/myapiserver.io.key
     SSLCertificateChainFile /etc/ssl/myapiserver/SectigoRSADomainValidationSecureServerCA.crt
     WSGIDaemonProcess restapi user=www-data group=www-data threads=4 python-path=/applications/restapi/env/lib/python3.10/site-packages
     WSGIProcessGroup restapi
     WSGIScriptAlias / /applications/restapi/restapi.wsgi
     WSGIPassAuthorization On
     <Directory /applications/restapi>
        <Files restapi.wsgi>
            Order allow,deny
            Allow from all
        </Files>
     </Directory>
     <Directory /applications/restapi/>
            Options FollowSymLinks
            AllowOverride None
            Require all granted
     </Directory>
     ErrorLog /applications/logs/restapi.error.log
     LogLevel warn
     CustomLog /applications/logs/restapi.access.log combined
</VirtualHost>

我已经验证了防火墙规则,并且请求是https://myapiserver.io:5001

Python 代码启动如下:

if __name__ == "__main__":
     app.run(host="0.0.0.0")

我不明白为什么它无法连接,而且我已经没有其他选择。任何帮助都将不胜感激。

相关内容