How to configure streamlit to serve an app to www?

streamlit app is running in a centOS stream 8 virtual machine. Access from intranet is fine but fails with “streamlit please wait… page” when accessed from www via subDomain.companyDomain.com

Tested R shiny app and a static page from same virtual machine and same same port. Both are successfully accessible from www with subDomain.companyDomain.com

network schema network schema note: subDomain != virtualMachineName

streamlit config.toml

[server]
port = 8585
headless = true
enableCORS = false
enableXsrfProtection = false
enableWebsocketCompression = false
address = "0.0.0.0"

[browser]
gatherUsageStats = false
serverAddress = "subDomain.companyDomain.com"

Note: company proxy server is ssl enabled.

Edit 1:

based on @dataprofessor answer, tried Apache reverse proxy.

/etc/httpd/conf.d/testApp.conf

<VirtualHost *:80>
    ServerName subDomain.companyDomain.com
    ServerAlias www.subDomain.companyDomain.com
    ProxyPreserveHost On
    ProxyPass "/" "http://local_IP:8585/"
    ProxyPassReverse "/" "http://local_IP:8585/"
    ErrorLog /var/log/httpd/testApp-error.log
    CustomLog /var/log/httpd/testApp-access.log common
</VirtualHost>

Interestingly, after redirecting http:local_IP:8585 to Apache virtualHost *:80, both local_IP:80 and subDomain.companyDomain.com hang at the same “streamlit… please wait” page.

(btw, httpd/testApp* log files are empty)

Edit 2

With nginx (this thread), both http://local_IP:8585 and http://local_IP:80 correctly display the app. subDomain.companyDomain.com continues to hang with “streamlit please wait” page.

server {
    listen 80;

    location / {
        proxy_pass http://local_IP:8585/;
            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;
    }
}

above tests suggest error in redirection to/from company proxy server.

Cross posted in serverfault because i am not sure if this problem is related to streamlit or server.

Hi @2n3m

I would recommend to look into ServerName, ProxyPass and ProxyPassReverse with Apache, which should allow you to redirect http://url:port to a subdomain. Please see this for ideas.

Hope this helps!

Best regards,
Chanin

thanks for the link @dataprofessor. edited original question based on your answer.

Problem is related to web socket blocked by company server.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.