Streamlit Application Hosting

I am relatively new to servers and networks, so any guidance would be highly appreciated.

I just made a streamlit application for my team, and want to deploy it so that anyone can use it. My team member has a server available, and I can access it via ssh. I was told that I can “host the app locally and then ssh tunnel to the web port.” Knowing very little about servers, hosting applications, etc, I am quite confused on what I am supposed to do. I vaguely understand ssh tunneling, port forwarding, etc, but I am not sure how the task of deploying the application will be accomplished by “hosting the app locally and then ssh tunneling to the web port.” Where do I start? What should be my steps? How can I host an application locally and ssh tunnel to the web port?

I would highly appreciate any help!!!

One simple way is to use a tool like ngrok.

You should be able to run a streamlit sever on your local machine, then ngrok will give u a public url.

But to host the app itself on a sever, you need to put your code on it and run the app itself on the server, which isn’t straightforward, as you need to install streamlit, any libs etc etc.

1 Like

@khalido
Ngrok will give a public URL as you said, so it may not be an appropriate solution in case he doesn’t want to share his app publicly (if I’m not mistaken). And It’s an opportunity to learn about SSH Tunneling, it can be useful to understand how to setup something like this!

@mali13
The first thing you have to do is to “host your app locally on the server”. That means you have to install your app in the server and run it on 127.0.0.1:8501. Once this is done, you won’t be able to access it directly as the app only listens to requests coming from your server only.

To access to your app, you can use an SSH Tunnel. The idea is to bind a port of your choice on your computer (let’s take 8000 for instance) which will redirect all the traffic from this port directly to the server.

You can do so by running the following command: ssh -L 8000:127.0.0.1:8501 server_user@server_name.

Now in your browser, if you go to the address 127.0.0.1:8000, your HTTP request will be forwarded to 127.0.0.1:8501 onto your server, and you’ll be able to access your app.

This method is good as you benefit from SSH security when communicating with the server from your computer.

Try googling SSH Tunnel or SSH Port Forwardingto get more information on those subjects. I’m sure you’ll find some blogs which will explain clearly what’s the concept behind it if my post isn’t good enough :stuck_out_tongue:

2 Likes

@Synode
Thanks a lot! I read up more on SSH port forwarding, and was able to get it to work. Your answer was really helpful!

1 Like