Caddy 2.0.0 crashed

1. Caddy version (caddy version):

v2.0.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=

2. How I run Caddy:

a. System environment:

Amazon Linux 2

b. Command:

service caddy start

[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target

[Service]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/config.json
ExecReload=/usr/bin/caddy reload --config /etc/caddy/config.json
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

d. My complete Caddyfile or JSON config:

{
	"admin": {
		"disabled": false,
		"listen": "0.0.0.0:2020",
		"config": {
			"persist": true
		}
	},
	"logging": {
		"sink": {
			"writer": {
			"output": "file",
			"filename": "/tmp/caddy-Go.log"
		}
		},
		"logs": {
			"default": {
				"writer": {
					"output": "file",
					"filename": "/tmp/caddy-tmp.log"
				},
				"encoder": {
					"format": "json"
				},
				"level": "WARN"
			}
		}
	},
	"apps": {
		"tls": {
			"automation": {
				"policies": [{
					"subjects": ["*.domain.com"],
					"issuer": {
						"module": "acme",
						"email": "soporte@domain.com",
						"challenges": {
							"dns": {
								"provider": {
									"name": "cloudflare",
									"api_token": "MY_API_TOKEN"
								}
							}
						}
					},
					"on_demand": false
				},
				{
					"issuer": {
						"module": "acme",
						"email": "soporte@domain.com"
					},
					"on_demand": true
				}],
				"on_demand": {
					"rate_limit": {
						"interval": "5m",
						"burst": 100
					},
					"ask": "http://certs.domain.com/delegated.php"
				}
			}
		},
		"http": {
			"http_port": 80,
			"https_port": 443,
			"servers": {
				"tiendas": {
					"@id": "domaincerts",
					"listen": [":80",":443"],
					"max_header_bytes": 41943040,
					"routes": [
						{
                                                        "group": "grupo2",
                                                        "match": [{
                                                                "host": [
                                                                        "dev-pos.domain.com"]
                                                        }],
                                                        "handle": [{
                                                                        "handler": "encode",
                                                                        "encodings": {
                                                                        "gzip": {},
                                                                        "zstd": {}
                                                                        }
                                                                },
                                                                {
                                                                "handler": "reverse_proxy",
                                                                "upstreams": [{
                                                                        "dial": "172.31.7.34:80"
                                                                }]
                                                        }],
                                                        "terminal": true
                                                },
						{
							"group": "grupo2",
							"match": [{
								"host": [
									"dev-apipos.domain.com",
									"dev-admintienda.domain.com",
									"dev-tienda.domain.com"]
							}],
							"handle": [{
									"handler": "encode",
									"encodings": {
									"gzip": {},
									"zstd": {}
									}
								},
								{
								"handler": "reverse_proxy",
								"upstreams": [{
									"dial": "172.31.4.60:80"
								}]
							}],
							"terminal": true
						},
						{
							"group": "grupo1",
							"match": [{
								"host": ["certs.domain.com"]
							}],
							"handle": [{
								"handler": "reverse_proxy",
								"transport": {
									"protocol": "fastcgi",
									"root": "/var/www/html/"
								},
								"upstreams": [{
									"dial": "unix//var/php.sock"
								}]
							}],
							"terminal": true
						},
						{
							"group": "grupo1",
							"match": [{
									"host": ["admintienda.domain.com"]
							}],
							"handle": [{
									"handler": "encode",
									"encodings": {
										"gzip": {},
										"zstd": {}
									}
								},
								{
									"handler": "reverse_proxy",
									"upstreams": [{
											"dial": "172.31.60.234:80"
									}]
							}]
						},
						{
							"group": "grupo1",
							"match": [{
									"host": ["apipos.domain.com"]
							}],
							"handle": [{
									"handler": "encode",
									"encodings": {
										"gzip": {},
										"zstd": {}
									}
								},
								{
									"handler": "reverse_proxy",
									"upstreams": [{
											"dial": "172.31.63.108:80"
									}]
							}]
						},
						{
							"group": "grupo1",
							"match": [{
									"host": ["api.domain.com"]
							}],
							"handle": [{
									"handler": "encode",
									"encodings": {
										"gzip": {},
										"zstd": {}
									}
								},
								{
									"handler": "reverse_proxy",
									"upstreams": [{
											"dial": "172.31.8.83:80"
									}]
							}]
						},
						{
							"group": "grupo1",
							"match": [{
								"host": ["*.domain.com"]
							}],
							"handle": [{
								"handler": "encode",
								"encodings": {
								"gzip": {},
								"zstd": {}
								}
							},
							{
								"handler": "reverse_proxy",
								"upstreams": [{
									"dial": "172.31.53.124:80"
								}]
							}],
							"terminal": true
						},
						{
							"group": "grupo1",
							"handle": [{
									"handler": "encode",
									"encodings": {
									"gzip": {},
									"zstd": {}
									}
								},
								{
								"handler": "reverse_proxy",
								"upstreams": [{
									"dial": "172.31.53.124:80"
								}]
							}],
							"terminal": true
						}
					]
				}
			}
		}
	}
}

3. The problem Iā€™m having:

Caddy crashed. This is the seconfd time. The first one I didnt know where to find the logs.

4. Error messages and/or full log output:

Aug 20 00:00:54 ip-172-31-0-158 caddy: panic: runtime error: invalid memory address or nil pointer dereference
Aug 20 00:00:54 ip-172-31-0-158 caddy: [signal SIGSEGV: segmentation violation code=0x1 addr=0x2d8 pc=0x8c4d71]
Aug 20 00:00:54 ip-172-31-0-158 caddy: goroutine 67822778 [running]:
Aug 20 00:00:54 ip-172-31-0-158 caddy: github.com/caddyserver/certmagic.(*Cache).updateOCSPStaples(0xc006547e50, 0x1942ec0, 0xc0049433c0)
Aug 20 00:00:54 ip-172-31-0-158 caddy: github.com/caddyserver/certmagic@v0.10.12/maintain.go:238 +0x271
Aug 20 00:00:54 ip-172-31-0-158 caddy: github.com/caddyserver/certmagic.(*Cache).maintainAssets(0xc006547e50)
Aug 20 00:00:54 ip-172-31-0-158 caddy: github.com/caddyserver/certmagic@v0.10.12/maintain.go:52 +0x20b
Aug 20 00:00:54 ip-172-31-0-158 caddy: created by github.com/caddyserver/certmagic.NewCache
Aug 20 00:00:54 ip-172-31-0-158 caddy: github.com/caddyserver/certmagic@v0.10.12/cache.go:113 +0x145
Aug 20 00:00:54 ip-172-31-0-158 systemd: caddy.service: main process exited, code=exited, status=2/INVALIDARGUMENT
Aug 20 00:00:54 ip-172-31-0-158 systemd: Unit caddy.service entered failed state.

5. What I already tried:

I dont know what to do

Just upgrade. :slight_smile: This was fixed quite a while ago.

1 Like

Yeap I found the issue on github.
I wil try to update but the last time I had to change several things in my config.json to make it work. :hot_face:

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