Caddy V2 + Varnish + Wordpress using Docker with SSL

Well the problem is you’re having Varnish make the request on port 80, but you also turn on a redirect on port 80 (http:// is port 80). You can’t do that, that’s in conflict.

Instead, I recommend serving your wordpress backend on a different port like 8080 or something, and have Varnish hit that. That way, you won’t need to worry about the redirect being overriden because it wouldn’t be.

Just change :80 in your Caddyfile to :8080, then in your Varnish config change .port = "80"; to .port = "8080"; and you should be good to go.

Port 8080 would only be accessible to docker services only, not to the outside world. That way you’re ensuring that outside services can’t just skip past HTTPS by making HTTP requests.

1 Like