Domain does not working

1. The problem I’m having:

Hi, I installed Caddy on Centos Stream 8 server. I updated Caddyfile and started Caddy via systemctl. I created the /var/www/html directory. Then I updated Caddyfile again. I restarted the service, but I cannot get any output from the domain.

2. Error messages and/or full log output:

Mar 18 01:50:06 host systemd[1]: caddy.service: Succeeded.
Mar 18 01:50:06 host systemd[1]: Stopped Caddy.
Mar 18 01:50:06 host systemd[1]: Starting Caddy...
Mar 18 01:50:06 host caddy[72043]: caddy.HomeDir=/var/lib/caddy
Mar 18 01:50:06 host caddy[72043]: caddy.AppDataDir=/var/lib/caddy/.local/share/caddy
Mar 18 01:50:06 host caddy[72043]: caddy.AppConfigDir=/var/lib/caddy/.config/caddy
Mar 18 01:50:06 host caddy[72043]: caddy.ConfigAutosavePath=/var/lib/caddy/.config/caddy/autosave.json
Mar 18 01:50:06 host caddy[72043]: caddy.Version=v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=
Mar 18 01:50:06 host caddy[72043]: runtime.GOOS=linux
Mar 18 01:50:06 host caddy[72043]: runtime.GOARCH=amd64
Mar 18 01:50:06 host caddy[72043]: runtime.Compiler=gc
Mar 18 01:50:06 host caddy[72043]: runtime.NumCPU=4
Mar 18 01:50:06 host caddy[72043]: runtime.GOMAXPROCS=4
Mar 18 01:50:06 host caddy[72043]: runtime.Version=go1.20.10
Mar 18 01:50:06 host caddy[72043]: os.Getwd=/
Mar 18 01:50:06 host caddy[72043]: LANG=en_US.UTF-8
Mar 18 01:50:06 host caddy[72043]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Mar 18 01:50:06 host caddy[72043]: NOTIFY_SOCKET=/run/systemd/notify
Mar 18 01:50:06 host caddy[72043]: HOME=/var/lib/caddy
Mar 18 01:50:06 host caddy[72043]: LOGNAME=caddy
Mar 18 01:50:06 host caddy[72043]: USER=caddy
Mar 18 01:50:06 host caddy[72043]: INVOCATION_ID=e24b47822e994e0c9ef017bd2a5dbe17
Mar 18 01:50:06 host caddy[72043]: JOURNAL_STREAM=9:126262
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.3109584,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.3137805,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//127.0.0.1:2019","//localhost:2019","//[::1]:2019"]}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.3139331,"logger":"http.auto_https","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"srv0","https_port":443}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.31395,"logger":"http.auto_https","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.3139923,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000272480"}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.3142083,"logger":"http","msg":"enabling HTTP/3 listener","addr":":443"}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.3144052,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.3144689,"logger":"http.log","msg":"server running","name":"remaining_auto_https_redirects","protocols":["h1","h2","h3"]}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.3144767,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["getseoranker.com"]}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.314695,"msg":"autosaved config (load with --resume flag)","file":"/var/lib/caddy/.config/caddy/autosave.json"}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.3147452,"msg":"serving initial configuration"}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.3148718,"logger":"tls.obtain","msg":"acquiring lock","identifier":"getseoranker.com"}
Mar 18 01:50:06 host systemd[1]: Started Caddy.
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.3165877,"logger":"tls.obtain","msg":"lock acquired","identifier":"getseoranker.com"}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.316706,"logger":"tls.obtain","msg":"obtaining certificate","identifier":"getseoranker.com"}
Mar 18 01:50:06 host caddy[72043]: {"level":"warn","ts":1710726606.3167427,"logger":"tls","msg":"storage cleaning happened too recently; skipping for now","storage":"FileStorage:/var/lib/caddy/.local/share/caddy","instance":"7211d9e4-747a-49e4-aaf8-5c0853720905","try_again":1710813006.3167403,"try_again_in":86399.9999995}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.316811,"logger":"tls","msg":"finished cleaning storage units"}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.3174036,"logger":"http","msg":"waiting on internal rate limiter","identifiers":["getseoranker.com"],"ca":"https://acme-v02.api.letsencrypt.org/directory","account":""}
Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.3174224,"logger":"http","msg":"done waiting on internal rate limiter","identifiers":["getseoranker.com"],"ca":"https://acme-v02.api.letsencrypt.org/directory","account":""}
Mar 18 01:50:07 host caddy[72043]: {"level":"info","ts":1710726607.384905,"logger":"http.acme_client","msg":"trying to solve challenge","identifier":"getseoranker.com","challenge_type":"tls-alpn-01","ca":"https://acme-v02.api.letsencrypt.org/directory"}
Mar 18 01:50:07 host caddy[72043]: {"level":"info","ts":1710726607.7483904,"logger":"tls","msg":"served key authentication certificate","server_name":"getseoranker.com","challenge":"tls-alpn-01","remote":"13.58.94.232:56516","distributed":false}
Mar 18 01:50:07 host caddy[72043]: {"level":"info","ts":1710726607.8207114,"logger":"tls","msg":"served key authentication certificate","server_name":"getseoranker.com","challenge":"tls-alpn-01","remote":"23.178.112.205:36663","distributed":false}
Mar 18 01:50:07 host caddy[72043]: {"level":"info","ts":1710726607.8634522,"logger":"tls","msg":"served key authentication certificate","server_name":"getseoranker.com","challenge":"tls-alpn-01","remote":"35.162.168.255:35154","distributed":false}
Mar 18 01:50:08 host caddy[72043]: {"level":"info","ts":1710726608.3568907,"logger":"http.acme_client","msg":"authorization finalized","identifier":"getseoranker.com","authz_status":"valid"}
Mar 18 01:50:08 host caddy[72043]: {"level":"info","ts":1710726608.3569176,"logger":"http.acme_client","msg":"validations succeeded; finalizing order","order":"https://acme-v02.api.letsencrypt.org/acme/order/1623909117/253216977687"}
Mar 18 01:50:09 host caddy[72043]: {"level":"info","ts":1710726609.7324688,"logger":"http.acme_client","msg":"successfully downloaded available certificate chains","count":2,"first_url":"https://acme-v02.api.letsencrypt.org/acme/cert/0420aeb68742414c7e63a018403a65a2109a"}
Mar 18 01:50:09 host caddy[72043]: {"level":"info","ts":1710726609.7328458,"logger":"tls.obtain","msg":"certificate obtained successfully","identifier":"getseoranker.com"}
Mar 18 01:50:09 host caddy[72043]: {"level":"info","ts":1710726609.7329035,"logger":"tls.obtain","msg":"releasing lock","identifier":"getseoranker.com"}

3. Caddy version: v2.7.6

h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=

4. How I installed and ran Caddy:

a. System environment:

Centos Stream 8

b. Command:

dnf install 'dnf-command(copr)'
dnf copr enable @caddy/caddy
dnf install caddy

d. My complete Caddy config:

getseoranker.com {
        # Set this path to your site's directory.
        # root * /usr/share/caddy
        root * /var/www/html
        # Enable the static file server.
        file_server browse

        # Another common task is to set up a reverse proxy:
        # reverse_proxy localhost:8080

        # Or serve a PHP site through php-fpm:
        # php_fastcgi localhost:9000
}

and here my cloudflare dns records:

A
getseoranker.com
34.90.19.171
DNS only
Auto

CAA
getseoranker.com
0 issue letsencrypt.org
DNS only

CNAME
www
getseoranker.com
DNS only
Auto

MX
getseoranker.com
mail.getseoranker.com
Priority 10
DNS only
Auto

and here caddy service status:

[xieneustr@host ~]$ sudo systemctl status caddy
● caddy.service - Caddy
   Loaded: loaded (/usr/lib/systemd/system/caddy.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2024-03-18 01:50:06 UTC; 9min ago
     Docs: https://caddyserver.com/docs/
 Main PID: 72043 (caddy)
    Tasks: 9 (limit: 100595)
   Memory: 27.5M
   CGroup: /system.slice/caddy.service
           └─72043 /usr/bin/caddy run --environ --config /etc/caddy/Caddyfile

Mar 18 01:50:06 host caddy[72043]: {"level":"info","ts":1710726606.3174224,"logger":"http","msg":"done waiting on internal rate limiter","identifiers":["getseoranker.com"],"ca":"https://acme-v02.api.letsencrypt.org>
Mar 18 01:50:07 host caddy[72043]: {"level":"info","ts":1710726607.384905,"logger":"http.acme_client","msg":"trying to solve challenge","identifier":"getseoranker.com","challenge_type":"tls-alpn-01","ca":"https://a>
Mar 18 01:50:07 host caddy[72043]: {"level":"info","ts":1710726607.7483904,"logger":"tls","msg":"served key authentication certificate","server_name":"getseoranker.com","challenge":"tls-alpn-01","remote":"13.58.94.>
Mar 18 01:50:07 host caddy[72043]: {"level":"info","ts":1710726607.8207114,"logger":"tls","msg":"served key authentication certificate","server_name":"getseoranker.com","challenge":"tls-alpn-01","remote":"23.178.11>
Mar 18 01:50:07 host caddy[72043]: {"level":"info","ts":1710726607.8634522,"logger":"tls","msg":"served key authentication certificate","server_name":"getseoranker.com","challenge":"tls-alpn-01","remote":"35.162.16>
Mar 18 01:50:08 host caddy[72043]: {"level":"info","ts":1710726608.3568907,"logger":"http.acme_client","msg":"authorization finalized","identifier":"getseoranker.com","authz_status":"valid"}
Mar 18 01:50:08 host caddy[72043]: {"level":"info","ts":1710726608.3569176,"logger":"http.acme_client","msg":"validations succeeded; finalizing order","order":"https://acme-v02.api.letsencrypt.org/acme/order/162390>
Mar 18 01:50:09 host caddy[72043]: {"level":"info","ts":1710726609.7324688,"logger":"http.acme_client","msg":"successfully downloaded available certificate chains","count":2,"first_url":"https://acme-v02.api.letsen>
Mar 18 01:50:09 host caddy[72043]: {"level":"info","ts":1710726609.7328458,"logger":"tls.obtain","msg":"certificate obtained successfully","identifier":"getseoranker.com"}
Mar 18 01:50:09 host caddy[72043]: {"level":"info","ts":1710726609.7329035,"logger":"tls.obtain","msg":"releasing lock","identifier":"getseoranker.com"}

What do you mean by “cannot get any output”? Show the error message you see. Make a request with curl -v and show what you get.

Your Caddy logs look fine, there’s no errors there.

$ curl -v https://www.getseoranker.com
*   Trying 62.72.164.64:443...
* connect to 62.72.164.64 port 443 failed: Connection refused
* Failed to connect to www.getseoranker.com port 443 after 32 ms: Couldn't connect to server
* Closing connection
curl: (7) Failed to connect to www.getseoranker.com port 443 after 32 ms: Couldn't connect to server

This is my DNS records:

What do you think is the mistake?

Something’s not right… why is it trying to connect to 62.72.164.64 when the DNS points to 34.90.19.171?

I think your system’s DNS might not be set up properly; DNS looks fine from my perspective:

$ host www.getseoranker.com                                                                                     
www.getseoranker.com is an alias for getseoranker.com.
getseoranker.com has address 34.90.19.171

$ host getseoranker.com                                                                                        
getseoranker.com has address 34.90.19.171

This isn’t a problem with Caddy, it’s a problem with your DNS config on whatever machine you ran that curl command, I think.

2 Likes