Running multiple apps on Apache

I want to run 2 streamlit apps on apache webserver: they can be started individually as:
www.calmbach.ch:8501
www.calmbach.ch:8502
I would like to call them with: www.calmbach.ch/traffic, www.calmbach.ch/envdata, and Apache would reroute the calls the respective ports.

This is what I did in the httpd.conf file, however, it does not work. I know there is a FAQ on this but it has not helped me. Does anyone have an example on how to configure several apps, I am sure this is done over and over or is there another way to run several apps on the same server?

<VirtualHost traffic:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /home/ec2-user/envdata
    ServerName calmbach.ch:8501
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost traffic:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /home/ec2-user/envdata
    ServerName calmbach.ch:8502
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
2 Likes

Hey @godot63 :slight_smile:,

Can you open those two different apps from localhost?, If yes, maybe you have a CORS problem.

If not, maybe you could try specifying an open port like this:

streamlit run e2e/scripts/st_disabled.py --server.port 8502
1 Like

hi @arraydude, thanks for getting back to me. I resolved parts of the problem in that I am now able to configure the VirtualHost entry so I can call the apps using the URL: www.calmbach.ch/traffic and www.calmbach.ch/covid. I am using the following configuration:

<Virtualhost *:80>
    ServerName www.calmbach.ch
    ServerAlias calmbach.ch

    documentroot /var/www/html/

    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} =websocket
    RewriteRule /covid ws://www.calmbach.ch:8501 [R]

    RewriteCond %{HTTP:Upgrade} !=websocket
    RewriteRule /covid http://www.calmbach.ch:8501 [R]

    RewriteCond %{HTTP:Upgrade} =websocket
    RewriteRule /traffic ws://www.calmbach.ch:8502 [R]

    RewriteCond %{HTTP:Upgrade} !=websocket
    RewriteRule /traffic http://www.calmbach.ch:8502 [R]
    
    ProxyPassReverse /placeholder http://localhost:8501
</Virtualhost>

however, this just translates my URL e.g. from www.calmbach.ch/covid to www.calmbach.ch:8501 and the URL opened by the browser is still www.calmbach.ch:8501. My company’s firewall does not allow opening URLs including unknown ports and blocks the access, I imagine this is standard for most firewalls. Many of the streamlit-apps I have seen do not show a port number when opening the URL, so I imagine this should be doable, I just cannot figure out how. Any help on this would be most appreciated. I work on an AWS-EC2 site and have an apache2 webserver. Let me know if you need any further information.

This seems related to a topic from our FAQ, did you check this?

yes, that is where I found the above configuration. it does remap an application folder, but then turns back to the url with the port number which is blocked by most firewalls. There are more examples for nginx, however I don’t want to change my webserver just for this if I dont have to.

1 Like

Hi @godot63, did you resolved this problem?

I have same need for self host deploy of multiple streamlit apps on our platform (https://hiplot.com.cn). And create a new issue on github (How to start multiple streamlit apps in the same port according to different directories? · Issue #2709 · streamlit/streamlit · GitHub).

Reuests

How to start multiple streamlit programs in the same port according to different directories?

Needs

localhost:8501/app-one/app.py
localhost:8501/app-two/app.py

or
domain-address/app-one/app.py
domain-address/app-two/app.py

or
systemctl start streamlit-server
And all apps in www/directorie could run as server