How to translate `--change-host-header` CLI argument to .Caddyfile configuration?

1. Output of caddy version:

v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=

2. How I run Caddy:

a. System environment:

Distributor ID:	Ubuntu
Description:	Ubuntu 22.10
Release:	22.10
Codename:	kinetic

b. Command:

sudo ../apps/caddy reverse-proxy --from localhost:9002 --to --change-host-header

d. My complete Caddy config:

None, this is what I’m trying to achieve,

3. The problem I’m having:

I want to express --change-host-header in the Caddyfile, because I also want to test Basic-Auth, which I can’t seem to do with the CLI.

5. What I already tried:


basicauth * {
  user $2a$14$.Cr5lYhUrGbhR6c0mhGBZ.8gLFRjE6SmvP3IyqPtTGcX7O6AS/6zS # "pass"

6. Links to relevant resources:

See the docs, which mention how to proxy over HTTPS:

https://localhost:9002 {
	basicauth {
		user $2a$14$.Cr5lYhUrGbhR6c0mhGBZ.8gLFRjE6SmvP3IyqPtTGcX7O6AS/6zS # "pass"

	reverse_proxy {
		header_up Host {upstream_hostport}
1 Like

Thanks @francislavoie!

It did not occur to me from the documentation that --change-host-header’s equivalent was header_up Host {upstream_hostport}, especially as the respective settings are described in completely different sections of the documentation and not linked with each other.

If the docs have a git repo, I’m happy to provide a PR for it!

Thanks again!

Well, if you’re looking to use the reverse_proxy directive, you should look at its docs as authoritative :man_shrugging:

The command-line interface and Caddyfile aren’t related. They’re two distinct ways of using Caddy, not connected to eachother. Their similarity is that they both produce JSON config that Caddy actually runs with.

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