Caddy v2 and caddyfile just serves plain sites

1. My Caddy version (caddy version):

https://github.com/caddyserver/caddy/actions/runs/70010904
→ caddy_v2_Linux_1e8af27

2. How I run Caddy:

a. System environment:

# lsb_release -a
LSB Version:	:core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:	CentOS
Description:	CentOS Linux release 7.7.1908 (Core)
Release:	7.7.1908
Codename:	Core

b. Command:

./caddy run --config="/opt/caddy/caddy_v2/caddyfile" --adapter="caddyfile"

c. My complete Caddyfile:

test.com {

#	push
#	cache

	reverse_proxy / 127.0.0.1:1091

	header / {
	Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"
	X-XSS-Protection "1; mode=block"
	X-Content-Type-Options "nosniff"
	X-Frame-Options "DENY"
	includeSubdomains
	}

#	ipfilter / {
#	rule allow
#	database /opt/caddy/GeoLite2-Country.mmdb
#	country US
#	}

	tls {
#	key_type rsa2048
	protocols tls1.2 tls1.3
	}
}

3. The problem I’m having:

I used caddy v1 since years. Caddy v2 seems to enter the stable state I wanted to try it out. To accomplish that I used the old caddyfile and wanted to migrate it to be used by caddy v2.
You can see the changes made above (the lines are commented). Also, I changed

proxy / 127.0.0.1:1091 {
transparent
}

to

reverse_proxy / 127.0.0.1:1091

since the “transparent” shouldn’t be needed anymore.

4. Error messages and/or full log output:

Basically there is no “error”. But no matter what I am trying, I cant get my sites being served by caddy v2 (they appear just plain white, with just the /favicon.ico loaded). If I start up caddy v1 with the same (with added “transparent” and “proxy”) config, it works perfectly fine.

/opt/caddy/caddy_v2/caddy run --config="/opt/caddy/caddy_v2/caddyfile" --adapter="caddyfile"

2020/04/03 20:53:56.294	INFO	using provided configuration	{"config_file": "/opt/caddy/caddy_v2/caddyfile", "config_adapter": "caddyfile"}
2020/04/03 20:53:56.297	INFO	admin	admin endpoint started	{"address": "localhost:2019", "enforce_origin": false, "origins": ["localhost:2019"]}
2020/04/03 20:53:56.298	INFO	http	enabling automatic HTTP->HTTPS redirects	{"server_name": "srv0"}
2020/04/03 20:53:56.298	INFO	http	enabling automatic HTTP->HTTPS redirects	{"server_name": "srv1"}
2020/04/03 20:53:56.298	INFO	http	enabling automatic HTTP->HTTPS redirects	{"server_name": "srv2"}
2020/04/03 20:53:56.298	INFO	http	enabling automatic HTTP->HTTPS redirects	{"server_name": "srv3"}
2020/04/03 20:53:56 [INFO][cache:0xc0007eebe0] Started certificate maintenance routine
2020/04/03 20:53:56.299	INFO	tls	cleaned up storage units
2020/04/03 20:53:56.300	INFO	http	enabling automatic TLS certificate management	{"domains": ["test.com"}
2020/04/03 20:53:56.312	INFO	autosaved config	{"file": "/root/.config/caddy/autosave.json"}
2020/04/03 20:53:56.312	INFO	serving initial configuration

5. What I already tried:

I tried it also with a minimal config. But that ended with the same result. But I got the message, that “cookies have to be enabled”. Therefore, I guessed caddy v2 throws different requests to the backend. So I tried it with → reverse_proxy + transport {http / http_ntlm / fastcgi}

test.com {
	reverse_proxy / 127.0.0.1:1091 {
	transport {http / http_ntlm / fastcgi}
	}
}

But that didn’t help either. For the test I did setup a “minio” instance.

6. Links to relevant resources:

In v2, this should be reverse_proxy * 127.0.0.1:1091

With /, you’re matching only requests to the root of your site. Instead, you want to match all requests, which you can do with the special * wildcard.

In your situation, because your proxy upstream doesn’t look like a path matcher (doesn’t start with /) then you can shorten it to reverse_proxy 127.0.0.1:1091

3 Likes

That worked… :see_no_evil:

Thank you so much! :slightly_smiling_face:

Sadly I didn’t see that in the documentation.

At the bottom of

it has some examples. And

explains the syntax for matchers (which is the 2nd argument to almost every directive). And finally,

the upgrade guide mentions the difference in syntax between v1 and v2.

2 Likes

wow… I should open my eyes :smiley:

The good thing is → I can confirm that this is solved now.

fastcgi transport: slice bounds out of range · Issue #3221 · caddyserver/caddy · GitHub

2 Likes

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