Reverse proxy any TCP connection (for database connections)

1. Caddy version (caddy version):


2. How I run Caddy:

I’m running Caddy directly from my OS.

a. System environment:


b. Command:

caddy run reverse-proxy --from :3307 --to :3306

3. The problem I’m having:

I’d like to use this to reverse proxy database connections, but it’s only working over HTTP.
I do not plan to use exactly this way in production, but I’m just trying to figure out the basics. I’m not sure if it’s even possible to do this, so I’ve started the simple way.

4. Error messages and/or full log output:

Running the above mentioned command, the output is this:

2021/06/09 17:59:08.456 WARN    admin   admin endpoint disabled
2021/06/09 17:59:08.456 INFO    tls.cache.maintenance   started background certificate maintenance     {"cache": "0xc0003bfce0"}
2021/06/09 17:59:08.456 INFO    tls     cleaning storage unit   {"description": "FileStorage:/root/.local/share/caddy"}
2021/06/09 17:59:08.456 INFO    autosaved config (load with --resume flag)      {"file": "/root/.local/share/caddy/autosave.json"}
Caddy proxying http://:3307 -> http://localhost:3306
2021/06/09 17:59:08.457 INFO    tls     finished cleaning storage units

5. What I already tried:

I’ve tried specifying the address, tried using the Caddyfile, but I didn’t manage to make caddy proxy every TCP connection.

Caddy’s standard reverse proxy is an HTTP reverse proxy. If you want to reverse proxy TCP, use the layer4 app:

1 Like

That’s exactly what I need. Thank you!

1 Like

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