【发布时间】:2021-06-12 08:32:34
【问题描述】:
我在 Flask 应用程序中提供破折号内容,该应用程序使用蓝图来注册路由。 应用设置:
- Dash 初始化为
route_pathname_prefix=/dashapp/
dash_app = dash.Dash(
server=server,
routes_pathname_prefix='/dashapp/',
)
dash_app.css.config.serve_locally = True
dash_app.scripts.config.serve_locally = True
- 使用 Flask 服务器注册的 dash 应用
- 使用 UWSGI 在 docker 容器内提供 Flask 应用程序
[uwsgi]
wsgi-file = </path/to/app.py>
callable = app
http = 0.0.0.0:8080
processes = 4
threads = 2
master = true
chmod-socket = 660
vacuum = true
die-on-term = true
到目前为止,本地一切正常。添加 Nginx 代理后,我遇到了以下问题
问题:
_dash-layout 和 _dash-dependencies 的 url 缺少反向代理 uri。例如,我在www.example.com/app/ 提供我的烧瓶应用程序。但是,在浏览器上,我看到_dash-layout 和_dash-dependencies 的请求来自www.example.com/dashpp/_dash-layout 而不是www.example.com/app/dashpp/_dash-layout。
我阅读了以下论坛discussion 并尝试应用解决方案,并收到此错误,
requests_pathname_prefix需要以'/'开头`
这是我的 Nginx 配置,
location /app/ {
proxy_pass http://localhost:<port>;
proxy_redirect http://localhost:<port> http://example.com/app/;
proxy_set_header Accept Encoding "";
sub_filter_types *;
sub_filter 'href="/' 'href="/app/';
sub_filter 'src="/' 'src="/app/';
sub_filter_once off;
}
任何人都有指向缺失内容的指针。我是新来的。所以,如果我错过了添加任何信息,请告诉我,我很乐意提供更多详细信息
谢谢
PS:我在破折号forum 中添加了相同的问题。将其发布在此处以获得更好的覆盖范围。
编辑:
为了添加额外的上下文,我发现_dash-component-suites 的 URL 是按预期生成的 www.example.com/app/dashpp/_dash-component-suites。我浏览了破折号源代码以了解 url 是如何生成的。 _dash-component-suites 和 _dash-layout 都以 routes_pathname_prefix 为前缀。 1.14.0版本dash.py的428-448行有构建url的代码。
这令人困惑!!!。
【问题讨论】:
标签: python flask plotly-dash