【问题标题】:Unable to load _dash-layout and _dash-dependencies from dash app running behind Nginx无法从运行在 Nginx 后面的 dash 应用程序加载 _dash-layout 和 _dash-dependencies
【发布时间】:2021-06-12 08:32:34
【问题描述】:

我在 Flask 应用程序中提供破折号内容,该应用程序使用蓝图来注册路由。 应用设置:

  1. 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
    
  1. 使用 Flask 服务器注册的 dash 应用
  2. 使用 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


    【解决方案1】:

    我可以通过从 nginx conf 中删除 sub_filter 指令并更新烧瓶应用程序中的 url_prefixes 来解决此问题。我采取的步骤发布在thisdash 论坛

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-15
      • 2020-01-10
      • 2016-11-29
      • 1970-01-01
      • 2017-09-11
      相关资源
      最近更新 更多