如何使用服务生和Nginx服务本地应用程序

2024-06-02 13:15:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个用flask作为服务器的dash(plotly)应用程序,可以在我们的Windows服务器上使用它来端口:8041使用服务员。我的启动服务生的代码如下

#!/usr/bin/env python3

from waitress import serve
from src.pacedash.app import server as application

if __name__ == "__main__":
    serve(application, threads=100, port=8041)

如果我使用python run,一切都很好_女服务员.py,但当我们的网络中有人导航到服务员:8041是url旁边的“不安全”警告。我们的IT供应商能够获得一个证书文件和密钥,但我不知道如何将它们引入我当前的设置中。在

我一直在尝试使用nginx,但我找不到一个与服务生一起设置它的指南,而且我对web应用程序或wsgi也不太熟悉,因为我主要是这里唯一的数据员。在


Tags: 端口代码fromimport服务器应用程序flaskapplication
2条回答

我一直在研究这个问题,并找到了解决办法。nginx.conf文件需要定义如下位置:

location /myapp/ {
       # Define the location of the proxy server to send the request to
       proxy_pass http://localhost:8041/myapp/;

       # standard proxy_set_header stuff below...
}

然后在Dash应用程序中,将url_base_路径名设置为相同的值:

^{pr2}$

我会用ngrok暴露你的web应用。它非常简单:

读这个:https://ngrok.com/

我可能误解了您的需求,因为我不熟悉服务员(为什么不在本地使用烧瓶提供应用程序?),但如果您需要测试live应用程序,您应该使用ngrok。在

相关问题 更多 >