我在Flask应用程序中提供dash内容,该应用程序使用蓝图注册路线。应用程序设置:
- 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在码头集装箱内提供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代理,我得到了以下问题
问题:CCD_ 2和CCD_ 3的URL缺少revers代理uri。例如,我正在www.example.com/app/
提供我的烧瓶应用程序。但是,在浏览器上,我看到对_dash-layout
和_dash-dependencies
的请求来自www.example.com/dashpp/_dash-layout
,而不是www.example.com/app/dashpp/_dash-layout
。
我阅读了下面的论坛讨论,并尝试应用该解决方案,但出现了这个错误,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;
}
任何人都能找到缺失的东西。我是个新手。所以,如果我错过了添加任何信息,请让我知道,我很乐意提供更多的细节
感谢
附言:我在dash论坛中添加了同样的问题。张贴在这里,以便更好地接触。
编辑:
为了添加额外的上下文,我发现_dash-component-suites
的url是按照预期的www.example.com/app/dashpp/_dash-component-suites
生成的。我浏览了dash源代码,以了解url是如何生成的。_dash-component-suites
和_dash-layout
都以routes_pathname_prefix
为前缀。1.14.0版本中dash.py的第428行到第448行有构建URL的代码。
这太令人困惑了!!!。
我通过从nginx conf中删除sub_filter
指令并更新flask应用程序中的url_prefix来解决这个问题。我采取的步骤张贴在这个仪表板论坛上