Caddy as HTTP proxy servicing some content from folders

1. The problem I’m having:

I want to use Caddy as an HTTP proxy accepting CONNECT requests, but for a certain website (HTTP, so no HTTPS MITM attempts) I want Caddy to serve content by himself if it’s present in a corresponding file path, if this fails serving it by having caddy connect on the requested HTTP server while using a SOCKS5 proxy

3. Caddy version:

2.6.2-5

4. How I installed and ran Caddy:

apt install caddy

a. System environment:

Debian bookworm

That’s a very old version. Please use the latest, v2.8.4. You should use our official installation instructions Install — Caddy Documentation

Then you’re looking for a forward proxy. Caddy doesn’t have this built-in, but you can use GitHub - caddyserver/forwardproxy: Forward proxy plugin for the Caddy web server

1 Like

Hi, been a bit busy here, in the meantime I’ve took a look at the project you linked, it simply acts as a forward proxy, you can’t even set a local server to fetch resources from or even set per-domain rules, I’d like to use caddy for substituting privoxy on my setup if possible, and the central point of my question was using caddy as a connect server while servicing content from it’s own file set when possible

Right, that’s what CONNECT is. See CONNECT - HTTP | MDN

Yes, you can do that with Caddy built with the forwardproxy plugin. You can set up request matchers to split traffic however you need.

But I don’t see any instructions to set traffic splitters on request matches in the README

Also how would redirecting traffic help in servicing files through caddy?

It’s just another HTTP handler. You can use Caddy’s request matchers to make some requests use other handlers Request matchers (Caddyfile) — Caddy Documentation