brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: caddy reverse-proxy sets up a proxy without a Caddyfile

Network and access
~/tips/tip-caddy-reverse-proxy-command

caddy reverse-proxy --from :2016 --to :9000

Starts a Caddy reverse proxy from the command line, with no config file.

Sometimes I just want to put a proxy in front of one service for a minute. Writing a config file for that feels like too much, and Caddy agrees.

caddy reverse-proxy --from :2016 --to :9000

The docs describe caddy reverse-proxy as a command that shuttles HTTP(S) traffic from the --from address to the --to address. There is nothing to write first. You can repeat --to to give several upstreams.

One detail about the address: unless you say otherwise, a --from with a hostname is assumed to be HTTPS. If you give a hostname and want certificates from Caddy’s own CA, --internal-certs forces that.

A few other flags from the command reference are worth knowing:

  • --change-host-header sets the Host header on the request to the upstream’s address.
  • --header-up and --header-down take a value like "Field: value" to change request or response headers.
  • --debug turns on verbose logging, and --access-log enables the access log.
  • --insecure disables TLS verification with the upstream.

That last one carries a capital-letters warning in the docs: it disables security by not verifying the upstream’s certificate. I’d only use it against something I control, and never as a permanent fix for a certificate error.

The command is a good fit for quick tests and one-off setups. For a proxy that stays, a Caddyfile with the reverse_proxy directive is easier to keep in version control.

Further reading: Caddy command line reference

Going deeper: Guide: fix a 502 Bad Gateway in Nginx Proxy Manager, with a checklist that finds the cause

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link