Deployed app loading a blank page with Streamlit title

I am trying to deploy my app on nginx. I have setup the nginx config to redirect port 8501 to my url.
It seems that the webserver config is fine, but that the Streamlit app does not load:

  • Going to the url, the page is blank, but the page title is “Streamlit”.
  • If I don’t start Streamlit in my server, the url returns “502 Bad Gateway”.
  • If I start a python server with python -m http.server 8501, the url gives me a file browser.

So it seems like the nginx config is mostly right, and that it is a problem with the Streamlit config.
I tried running the app with different options (–server.enableCORS=false, --server.enableXsrfProtection=false, --server.enableWebsocketCompression=false), but it does not help.

Any idea how to solve this issue?

Hi @Blueberry,

Thanks for posting!

Can you share your nginx and Streamlit config files?

Caroline :balloon:

I don’t have a streamlit config file.
My nginx config is

server {
        listen 443 ssl;
        ssl_certificate .../fullchain.pem; # managed by Certbot
        ssl_certificate_key .../privkey.pem; # managed by Certbot
        ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers         HIGH:!aNULL:!MD5;

        root /storage/html/;
        index index.html index.htm;

        server_name localhost mydomain.com
        gzip_static on;

        location /vapp {
                proxy_pass http://127.0.0.1:8501/;
        }
        location ^~ /static {
                proxy_pass http://127.0.0.1:8501/static/;
        }
        location ^~ /healthz {
                proxy_pass http://127.0.0.1:8501/healthz;
        }
        location ^~ /vendor {
                proxy_pass http://127.0.0.1:8501/vendor;
        }
        location /vapp/stream {
                proxy_pass http://127.0.0.1:8501/stream;
                proxy_http_version 1.1;
                # proxy_redirect off;
                # proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                # proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header Host $host;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_read_timeout 86400;
        }

        location ~ /\.git {
                deny all;
        }
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to index.html
                try_files $uri $uri/ /index.html;
        }
        location ~ ^/index.php/(.*)$ {
                return 301 /$1;
        }
        error_page 404 /404.html;
}

The issue disappeared, not sure why.
It might have been due to some browser caching.

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