Shared reverse proxy issue

1. Caddy version:


2. How I run Caddy:

a. System environment:

systemd on archlinux

b. Command:

systemctl start caddy

c. Service/unit/compose file:


d. My complete Caddyfile or JSON config:

(complete) {
    reverse_proxy /favicon.ico https://www.domain.tld
    reverse_proxy /robots.txt https://www.domain.tld
    tls me@domain.tld
    header -server

www.domain.tld {
	root * /srv/http/www
	header -server

app1.domain.tld {
	import complete
	reverse_proxy localhost:3001

app2.domain.tld {
	import complete
	reverse_proxy localhost:3002

3. The problem I’m having:

I can not request /favicon.ico or /robots.txt with this configuration. I was using Caddy v1 successfully this way.

4. Error messages and/or full log output:

On server side, Caddy load increases as soon as I request these files. On client side, I get either 308 as status code or the request never ends.

5. What I already tried:

  1. Invert directives import complete and reverse_proxy ....
  2. Remove scheme in reverse_proxy directive of shared configuration block complete.

6. Links to relevant resources:


There’s a lack of detail here, but I’m going to guess that since you’re proxying to another site with https://, it’s probably redirecting you because it doesn’t recognize the Host header passed through.

You can overwrite the Host header like this:

reverse_proxy https://www.domain.tld {
	header_up Host {http.reverse_proxy.upstream.hostport}

I’d write your config like this, to avoid duplication:

@proxiedFiles path /favicon.ico /robots.txt
reverse_proxy @proxiedFiles https://www.domain.tld {
	header_up Host {http.reverse_proxy.upstream.hostport}
1 Like

Thank you @francislavoie,

Your fix works like a charm.

1 Like

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