Reverse Proxy is not working

Hello everyone,

1. The problem I’m having:

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:

2. Error messages and/or full log output:

Jul 18 08:52:17 server1 caddy[31908]: {"level":"info","ts":1689670337.360512,"logger":"tls.cache.maintenance","msg":"certificate expires soon; queuing for renewal","identifiers":["42.252.231.56"],"remaining":14195.639490416}
Jul 18 08:52:17 server1 caddy[31908]: {"level":"info","ts":1689670337.3615906,"logger":"tls.cache.maintenance","msg":"attempting certificate renewal","identifiers":["42.252.231.56"],"remaining":14195.638410303}
Jul 18 08:52:17 server1 caddy[31908]: {"level":"info","ts":1689670337.3618279,"logger":"tls.renew","msg":"acquiring lock","identifier":"42.252.231.56"}
Jul 18 08:52:17 server1 caddy[31908]: {"level":"info","ts":1689670337.3649905,"logger":"tls.renew","msg":"lock acquired","identifier":"42.252.231.56"}
Jul 18 08:52:17 server1 caddy[31908]: {"level":"info","ts":1689670337.3651657,"logger":"tls.renew","msg":"renewing certificate","identifier":"42.252.231.56","remaining":14195.634835059}
Jul 18 08:52:17 server1 caddy[31908]: {"level":"info","ts":1689670337.3662295,"logger":"tls.renew","msg":"certificate renewed successfully","identifier":"42.252.231.56"}
Jul 18 08:52:17 server1 caddy[31908]: {"level":"info","ts":1689670337.3662722,"logger":"tls.renew","msg":"releasing lock","identifier":"42.252.231.56"}
Jul 18 08:52:17 server1 caddy[31908]: {"level":"info","ts":1689670337.3663867,"logger":"tls","msg":"reloading managed certificate","identifiers":["42.252.231.56"]}
Jul 18 08:52:17 server1 caddy[31908]: {"level":"warn","ts":1689670337.3666759,"logger":"tls","msg":"stapling OCSP","error":"no OCSP stapling for [42.252.231.56]: no OCSP server specified in certificate","identi...["42.252.231.56"]}
Jul 18 08:52:17 server1 caddy[31908]: {"level":"info","ts":1689670337.3667157,"logger":"tls.cache","msg":"replaced certificate in cache","subjects":["42.252.231.56"],"new_expiration":1689713538}

3. Caddy version:

v2.6.4

4. How I installed and ran Caddy:

By downloading caddy binary.

a. System environment:

RHEL 7.9
Architecture: x86_64

b. Command:

Release v2.6.4 · caddyserver/caddy · GitHub - I downloaded the package which is compatible with my environment and depackage in the server and run.

c. Service/unit/compose file:

caddy_2.6.4_linux_amd64.tar.gz - I downloaded this package.

d. My complete Caddy config:

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

5. Links to relevant resources:

There are not any relevant sources.

Please fill out the help topic template, as per the forum rules. We can’t help you otherwise.

I couldn’t find the template, can you share with me please?

Click “New Topic” on the homepage, you’ll see the template in the text box. Copy that template, close the new topic menu, then write a new reply in this thread with that template.

I changed it, thank you!

You didn’t configure your Caddyfile with a domain, you only used an IP address, so Caddy won’t respond to requests for that domain.

This is is just for a placeholder. I have access to the webserver, I can visit the website but when I try to visit https://ip-address/subdir it is not working and forwarding me to https://ip-address. I think this is not about Caddy webserver, Streamlit can cause that. I will continue to investigate. Thanks for your reply.

See this article, I think this is what you’re running into:

Essentially, if the upstream app isn’t aware of the subpath, it won’t work. If they have something like a “base path” config, you’ll need to set that. If they don’t, then you have no choice but to use a subdomain instead of a subpath for routing to it.

Hi Francis,

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! Thanks for your help!

1 Like

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