Setting up Caddy as a reverse proxy

Last updated:

We like using Caddy because it makes setting up the reverse proxy and TLS a breeze.

docker run -p 80:80 -p 443:443 caddy caddy reverse-proxy --to --from <YOUR_TRACKING_DOMAIN> --change-host-header

You'll want to sub out YOUR_TRACKING_DOMAIN for whatever domain you use for proxying to PostHog. We'd suggest something like or the like.

Make sure your DNS records point to your machine and that ports 80 and 443 are open to the public and directed toward Caddy.

If you want to use a config file instead, you can use something of the form:

:{$PORT} {
header {
Access-Control-Allow-Origin https://<your domain name>
reverse_proxy {
header_up Host
header_down -Access-Control-Allow-Origin


Was this page useful?

Next article

Using Cloudflare as a reverse proxy

In Cloudflare, create a new CNAME record for your domain. It should point to or depending on your region, and have proxy enabled (e.g. CNAME, e,, proxy enabled ). Finally, use Page Rules to change the Host header to or depending on which PostHog region you are using. Cloudflare does require your domain to be hosted with them, and using them does more than just proxying requests, such as blocking traffic from…

Read next article