1. The problem I’m having:
I installed Caddy2 on a VPS that has IPv6 disabled and Caddy will not start. Judging from the error, it looks like Caddy admin is trying to bind to [::1]. How can I totally disable IPv6 support in Caddy? I never encountered this issue with previous version such as v2.6.2 and I use the same exact Caddyfile. Below is how I disable IPv6 on the VPS:
# grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) net.ifnames=0 ipv6.disable=1"
# reboot
2. Error messages and/or full log output:
[root@tx ~]# caddy start
Error: loading initial config: loading new config: starting caddy administration endpoint: listen tcp [::1]:2019: socket: address family not supported by protocol
Error: caddy process exited with error: exit status 1
[root@tx ~]# caddy stop
2023/08/31 03:27:28.450 WARN failed using API to stop instance {"error": "performing request: Post \"http://localhost:2019/stop\": dial tcp [::1]:2019: socket: address family not supported by protocol"}
Error: performing request: Post "http://localhost:2019/stop": dial tcp [::1]:2019: socket: address family not supported by protocol
If I re-enable IPv6 support on the VPS, Caddy starts:
[root@tx ~]# caddy start
2023/08/31 11:19:11.071 INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["//[::1]:2019", "//127.0.0.1:2019", "//localhost:2019"]}
2023/08/31 11:19:11.071 INFO serving initial configuration
Successfully started Caddy (pid=1496) - Caddy is running in the background
3. Caddy version:
v2.7.4
4. How I installed and ran Caddy:
It was installed with a third-party script: https://github.com/loyess/Shell/blob/master/ss-plugins.sh
Caddy is started in the background as a service.
a. System environment:
AlmaLinux 8.8
b. Command:
Caddy start
c. Service/unit/compose file:
d. My complete Caddy config:
tx.example.com:443 {
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains"
-Server
}
encode gzip
log {
output file /var/log/caddy-access.log
format json
}
tls /root/.acme.sh/tx.example.com_ecc/fullchain.cer /root/.acme.sh/tx.example.com_ecc/tx.example.com.key {
protocols tls1.3
}
reverse_proxy /fOZ46 localhost:15140
#reverse_proxy https://www.bing.com {
reverse_proxy 127.0.0.1:81 {
#header_up Host {http.reverse_proxy.upstream.hostport}
#header_up X-Real-IP {http.request.remote}
#header_up X-Forwarded-For {http.request.remote}
#header_up X-Forwarded-Port {http.request.port}
#header_up X-Forwarded-Proto {http.request.scheme}
}
}