python - 如何使用 Waitress 和 Nginx 服务本地应用程序
问题描述
我有一个使用flask作为服务器设置的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 不太熟悉,因为我主要在这里作为唯一的数据人员工作。
解决方案
我一直在研究同样的问题并有解决方案。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/')
推荐阅读
- r - 将图形/表格标题和标签放在图形/表格的正上方,以避免多余的空白
- java - 使用视图绑定扩展基本活动的 Android 活动
- javascript - 拒绝获取不安全的标题“年龄”
- javascript - 开头没有空格 + 中间留有空格
- javascript - 错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件),但得到:未定义。反应
- python - 如何使用“包含”从带有 Selenium 的网站获取多个 Xpath?
- javascript - 为什么它显示“onclick”不可扩展
- python - 使用管道传输 STDIN 时如何在 Python 中禁用 TTY 回显
- sql-server - 在 SQL WHERE IN 语句中使用变量
- python - python计时器触发错误未找到作业功能