Reverse-Proxy self-hosted Supabase with Caddy

1. The problem I’m having:

Hi, im pretty new here and never did anything with caddy before.
Currently im trying to secure my Supabase studio that runs at port 3000 because Docker runs on a Windows-Server and we dont want employees to just connect to the database.
I have 2 Docker-Containers, the first one is caddy with the latest version, the second one is Supabase (i followed the tutorial from their site).
How can i reverse-proxy the Container that runs on port 3000 when Caddy is in another Container?

2. Error messages and/or full log output:

3. Caddy version:

Docker latest

4. How I installed and ran Caddy:

Docker-Image: docker pull caddy

a. System environment:

Windows 10 Pro, Docker

d. My complete Caddy config:

localhost {
        reverse_proxy /rest/v1/* localhost:8000
        reverse_proxy /auth/v1/* localhost:8000
        reverse_proxy /realtime/v1/* localhost:8000
        reverse_proxy /storage/v1/* localhost:8000
        reverse_proxy * localhost:3000
        basicauth / {
                joker $2y$10$oPH1//179OXYwKeA3gXfjO4DmoVChbOa66yQ431wItFblhT.W.IAG
        }
}

5. Links to relevant resources:

1 Like

localhost in a container means “this same container”.

You need to use the other container’s name as the hostname. So if your container is named supabase, you’d do reverse_proxy supabase:3000.

Make sure both containers share a Docker network.

FYI this will only require authentication for exactly / and nothing else. If you want auth for all pages, you should use remove the / path matcher (leaving it blank means “match all requests”. See Request matchers (Caddyfile) — Caddy Documentation

You can simplify this by using a single path matcher for all of these:

@api path /rest/v1/* /auth/v1/* /realtime/v1/* /storage/v1/*
reverse_proxy @api supabase:8000
2 Likes

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