Streamlit Reverse Proxy Problem (Caddy Webserver)

Hello everyone,

I am using caddy as a reverse proxy. I deployed an streamlit app and configured Caddyfile to use as a reverse proxy for streamlit application URL (http://ip-address:8501). It is working perfectly, but I also need to deploy second streamlit app and access it on (http://example.com/secondapp). I configured my Caddyfile like that:

42.252.231.56 {
        reverse_proxy http://42.252.231.56:8501
        #root * /var/www
        file_server
}

42.252.231.56/secondapp {
        reverse_proxy http://42.252.231.56:8502
        file_server
}

How can I solve this?

Hi @can,

Iโ€™m not familiar with Caddy, but skimming through their docs, you may want to use paths instead of URLs for the different applications.

Would you mind trying this and see if it solves the issue?

42.252.231.56 {
    route {
        reverse_proxy /secondapp/* http://42.252.231.56:8502
        reverse_proxy http://42.252.231.56:8501
    }
}

Thanks,
Charly

Hi Charly,

Thanks for your quick reply. I tried it but it is not working. I got this message alwaysโ€ฆ

image

Ok, thanks for your feedback!

Note that Streamlit, by default, doesnโ€™t support running in a subdirectory as it expects apps to be deployed at the root of a domain.

Would you be able to run your Streamlit apps on their own subdomain rather than a subdirectory?

If not, I may pass your issue to the devs as they may be able to find a workaround for your issue.

Thanks,
Charly

I need to use in subdir. I appreciate it if you pass that to your dev team,

Thank you so much.

1 Like

Sure! Iโ€™ve passed it to the Devs.

Thanks for your patience :slight_smile:

Charly

1 Like

Hi again Charly,

I solved the issue, I just start second streamlit app by server.baseUrlPath option. I defined the path which I defined in my Caddyfile and it worked!

1 Like

Oh, good to hear you managed to sort it!

Happy streamlitinโ€™! :balloon:

Charly

1 Like

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