1. The problem I’m having:
Hi! I have three domains which I want to use.
example.com
example.de
example.co
.com ist die main domain which also uses two subdomains dev.example.com and staging.example.com.
The .co and .de shall be used as alias domains. I thought I can use wildcard certs to make it easier. But the problem is, the .de and .co domain is not working at all - for both I got the response " Web server is returning an unknown error Error code 520" from Cloudflare.
The subdomains for the main domain, staging and dev are working as expected. But the main domain itself is making problems also. Here I can open my wordpress instance when using www.example.com but not example.com alone. Here i also get the same error message " Web server is returning an unknown error Error code 520".
2. Error messages and/or full log output:
2023/11/06 09:58:20.805 INFO http.log.access.log0 handled request {"request": {"remote_ip": "162.158.yy.xx", "remote_port": "58102", "client_ip": "162.158.yy.xx", "proto": "HTTP/2.0", "method": "GET", "host": "www.example.com", "uri": "/", "headers": {"User-Agent": ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"], "Sec-Fetch-User": ["?1"], "Sec-Fetch-Dest": ["document"], "Cdn-Loop": ["cloudflare"], "Upgrade-Insecure-Requests": ["1"], "X-Forwarded-Proto": ["https"], "Sec-Ch-Ua": ["\"Chromium\";v=\"119\", \"Not?A_Brand\";v=\"24\""], "Sec-Ch-Ua-Mobile": ["?0"], "Sec-Ch-Ua-Platform": ["\"macOS\""], "Sec-Fetch-Mode": ["navigate"], "Cf-Ray": ["821c7a3beb183626-FRA"], "X-Forwarded-For":
3. Caddy version:
v2.7.5 h1:HoysvZkLcN2xJExEepaFHK92Qgs7xAiCFydN5x5Hs6Q=
4. How I installed and ran Caddy:
a. System environment:
Debian 12, ARM
c. Service/unit/compose file:
# caddy.service
#
# For using Caddy with a config file.
#
# Make sure the ExecStart and ExecReload commands are correct
# for your installation.
#
# See https://caddyserver.com/docs/install for instructions.
#
# WARNING: This service does not use the --resume flag, so if you
# use the API to make changes, they will be overwritten by the
# Caddyfile next time the service is restarted. If you intend to
# use Caddy's API to configure it, add the --resume flag to the
# `caddy run` command or use the caddy-api.service file instead.
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target
[Service]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
d. My complete Caddy config:
*.example.com, *.example.de, *.example.co {
tls {
dns cloudflare a-TuImIakmNlEUnKNHAQG3P2VKmZYuKs48n0tERY
}
@wpaliases host www.example.com, *.example.de, *.example.co
handle @wpaliases {
redir https://example.com{uri}
}
@wpts-prod host example.com
handle @wpts-prod {
root * /var/www/vhosts/example.com/public
encode zstd gzip
php_fastcgi unix//var/run/php8.2-fpm-wp-ts-prod.sock
file_server
@disallowed {
path /xmlrpc.php
path *.sql
path /wp-content/uploads/*.php
}
rewrite @disallowed '/index.php'
}
@wpts-stage host staging.example.com
handle @wpts-stage {
root * /var/www/vhosts/staging.example.com/public
encode zstd gzip
php_fastcgi unix//var/run/php8.2-fpm-wp-example-dev.sock
file_server
@disallowed {
path /xmlrpc.php
path *.sql
path /wp-content/uploads/*.php
}
rewrite @disallowed '/index.php'
}
@wpts-dev host dev.example.com
handle @wpts-dev {
root * /var/www/vhosts/dev.example.com/public
encode zstd gzip
php_fastcgi unix//var/run/php8.3-fpm-wp-example-dev.sock
file_server
@disallowed {
path /xmlrpc.php
path *.sql
path /wp-content/uploads/*.php
}
rewrite @disallowed '/index.php'
}
handle {
abort
}
log {
output file /var/log/caddy/example.com
format console
}
}