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-headersets the Host header on the request to the upstream’s address.--header-upand--header-downtake a value like"Field: value"to change request or response headers.--debugturns on verbose logging, and--access-logenables the access log.--insecuredisables 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