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

时间:2019-02-26 19:30:43

标签: python nginx windows-server-2008 plotly-dash waitress

我有一个使用dash瓶作为服务器的破折号(plotly)应用程序,可以使用服务生在Windows Server上将其提供给端口: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_waitress.py,一切工作都很好,除了当我们网络上的某人导航到servename:8041时,URL旁会显示“不安全”警告。我们的IT供应商能够获得证书文件和密钥,但是我不确定如何将其用于当前设置。

我一直在尝试使用nginx,但是我找不到与女服务员一起设置它的指南,并且我对Web应用程序或wsgi不太熟悉,因为我主要是在这里担任独行数据人。

2 个答案:

答案 0 :(得分:0)

我将使用ngrok公开您的Web应用程序。非常简单:

阅读:https://ngrok.com/

我可能会误解您的需求,因为我不熟悉女服务员(为什么不仅仅使用flask来在本地提供应用程序?),但是如果您需要测试在线应用程序,则应该使用ngrok。

>

答案 1 :(得分:0)

我一直在解决同一问题,并有一个解决方案。 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_pathname设置为相同的值:

app = dash.Dash(__name__, url_base_pathname='/myapp/')