在 nginx + docker 上部署 Streamlit 时出错

问题描述 投票:0回答:1

我使用streamlit开发了一个简单的多页面网站,与各种容器化后端通信,我试图将其部署在nginx上。

如果我将容器端口链接到本地主机,则网站可以正常工作,但如果我尝试解聚它,页面加载时只会说“请稍候”,我得到this error

我对这一切都很陌生,但我认为错误一定出在我的 nginx 配置文件上,所以我将其留在这里。

upstream webapp{
    server webapp:8501;
}


server {
    listen 80;

    location / {
        proxy_pass http://webapp/;
    }
    location ^~ /static {
        proxy_pass http://webapp/static;
    }
    location _stcore/health {
        proxy_pass http://webapp/healthz;
    }
    location ^~ /vendor {
        proxy_pass http://webapp/vendor;
    }


    # location /stream {          # for old streamlit versions
    location ^~ _stcore/stream {   # new versions
        proxy_pass http://webapp/_stcore/stream;
        proxy_http_version 1.1; 
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 86400;
}

    

}

如果有人可以帮助我,我将非常感激

我尝试过的:

  • 我已经阅读了有关它的各种问题,因此我在streamlit的.toml文件中设置了enableCORS = false,enableXsrfProtection = false和headless = true。
  • 由于旧的streamlit版本没有这个问题,我尝试降级它,但我建立的网站需要streamlit 1.20或更高版本
  • 对 .conf 位置进行了各种更改,但没有任何效果
docker nginx websocket nginx-reverse-proxy streamlit
1个回答
0
投票

我设法找到了解决方法

https://github.com/joy13975/streamlit-endpoint-patch

不幸的是它仅适用于streamlit 1.19.0

© www.soinside.com 2019 - 2024. All rights reserved.