Use multiple server management tools on the same domain

1. The problem I’m having:

Is it possible to have multiple reverse proxies related to server management on the same domain?

I tried different things as:

admin.example.com {
        route {
        authorize with guests_policy
handle_path /stats/* {
        reverse_proxy localhost:8080 {
        import custom_404
        }
        import serve_fonts
        import serve_ohno
        }
}
}

This runs monotorix and doesn’t seem to work at all, going into /stats/monotorix shows a blank page

With the following usage it works but there are some issues

admin.example.com/stats {
        route {
        authorize with guests_policy

        reverse_proxy localhost:8080 {
        import custom_404
        }
        import serve_fonts
        import serve_ohno
        }
}

Going to stats/monotorix works, this is just an entry endpoint where you can select for which date range to have the logs. After you click OK, it redirects to /monitorix-cgi which breaks. Maybe there is a way to override this from caddy configuration?

2. Error messages and/or full log output:

n/a

3. Caddy version:

v2.7.4 h1:J8nisjdOxnYHXlorUKXY75Gr6iBfudfoGhrJ8t7/flI= (from caddy-security repo)

4. How I installed and ran Caddy:

From caddy-security repo

a. System environment:

Ubuntu 20.04

b. Command:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

c. Service/unit/compose file:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

d. My complete Caddy config:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

5. Links to relevant resources:

Are you sure you didn’t get your two config examples backwards?

This wouldn’t work because it would only match exactly /stats and nothing else. It would need to be /stats*.

But anyway, path matchers in the site address is deprecated and should not be used.

This will match /stats/monotorix, but it will strip /stats from the request before proxying. If you need to keep that part of the path, you should be using handle, not handle_path.


Please completely fill out the help topic template, as per the forum rules. Show your logs, as explained in the template.

Show your full config, not just one part. Things in your import snippets can affect behaviour.

Ah yeah sorry, I got the path backward wrong. No I want to strip the /stats| so /stats/monitorixsends me tolocalhost:8080/monotorix, but after going further in monotorix it completly gets rid of /stats`.

So what happens with handle_path:

The imports are just some 404 handles, and most things in the config is the caddy-secure configuration. Also the logs all it prints are logs related to caddy-secure.

That’s a classic case of the “subfolder problem”:

Your app needs to be aware of the subpath. If it doesn’t have a “base path” config of somekind, your best option is to use a subdomain instead.

Thanks. I found that handle_path worked, monitorix was broken, it was breaking the /monitorix-cgi to /monitorix-cgi/monitorix-cgi.

Anyway using handle /stats/* and setting the base url in monitorix configuration worked.

1 Like

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