Home > database >  How does one display a URL in the address bar when running streamlit?
How does one display a URL in the address bar when running streamlit?

Time:12-09

Suppose I have a website name. Suppose I get the DNS configured to direct that website to a particular IP address (cloud resource).

Next, I run my linux developed streamlit app on the cloud resource and navigate to that app with my PC browser.

Everything is great, everything works, I am able to leverage my linux code in Windows (yay), but I am not ready to share this site with others.

Embarrassingly, my raw IPAddress and port is displayed in the URL of the browser when accessing the streamlit content.

It seems that streamlit is very stubborn when it comes to displaying the IP address, as I have configured Nginx to display my website name instead to no avail.


Without diving too deep, is there any easy way to configure streamlit to display some string information or website name instead of the naked IP 123.208.000:8502 alongside the "your connection is insecure" lock symbol?

CodePudding user response:

Inside my nginx conf, I have the following lines:

server {
    absolute_redirect off;
    listen 80 default_server;
    server_name my.domain.name.com;

    if ($http_x_forwarded_proto = "http") {
        return 301 https://my.domain.name.com$request_uri;
    }

    location /my-streamlit-dashboard {
        proxy_pass http://127.0.0.1:8501/my-streamlit-dashboard;
        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;
    }
}

Then, I run my Streamlit app with the following command:

streamlit run my_app.py --server.port 8501 --server.baseUrlPath /my-streamlit-dashboard/ --server.enableCORS false --server.enableXsrfProtection false

In my case, the app is accessible at: https://my.domain.name.com/my-streamlit-dashboard/.

  • Related