On-Demand TLS questions

Hi,

Thank you very much for making this. I have a few questions:

  1. What should be the nature of the ask? A POST, GET and what should it return if the ask is valid?

  2. What does the https:// right after configurations on_demand_tls do?

It’s documented here:

It’s a GET request, with the domain query parameter set to the domain in the request – only requests for domains Caddy doesn’t have a certificate for will be sent. Respond with a 200 status if the domain is known (in your database, as registered by the customer), 400 otherwise.

This is the site address for the site block. See how the Caddyfile is structured:

https:// is essentially a catch-all for all HTTPS requests to Caddy, since you don’t necessarily know the domain with which users will make requests.

1 Like

Thank you very much @francislavoie

One more question please. I have applied the Caddyfile, ran caddy adapt, then caddy fmt when presented with the error [WARNING][caddyfile] /home/ubuntu/Caddyfile:2: input is not formatted with 'caddy fmt' and all seems to check out.

I then restarted caddy with sudo systemctl reload caddy and pointed the server’s IP to my domain test.domain.com with an A record in the DNS.

However, I will still see the default Caddy page that says “congratulations” with other instructions on how to get Caddy to work on visiting test.domain.com.

Here is the Caddyfile I used:

{
    on_demand_tls {
        ask      http://localhost:5000/exist
        interval 2m
        burst    5
    }
}

https://

tls {
    on_demand
}
reverse_proxy localhost:5000

Any idea what I am doing wrong?

caddy fmt expects the Caddyfile to be using tabs, not spaces. You can run it with the --overwrite flag to let Caddy write the formatted output to file.

Did you edit the Caddyfile at /etc/caddy/Caddyfile? That’s the location of the Caddyfile used by the systemd service.

Thank you very much for your patience.

I would move my Caddyfile to the right location and ran caddy fmt --overwrite, then reloaded the server.

The behavior changed, it would give curl: (35) error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error from the terminal. From the browser I would get:

This site can’t provide a secure connection
test.domain.com sent an invalid response.
ERR_SSL_PROTOCOL_ERROR

Any idea how to fix this?

Is that a domain that you own, for which you have DNS pointed to your server? Please don’t obfuscate your domain, it only makes this harder.

What’s in Caddy’s logs? See the journalctl command in the docs for how to see your logs:

1 Like

Yes, sure. I owe the domain - xomble.com. The A record points to test.xomble.com.
Here is the logs:

Sep 21 11:37:14 ubuntu kernel: Linux version 5.4.0-1045-aws (buildd@lcy01-amd64-026) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)) #47-Ubuntu SMP Tue Apr 13 07:02>
Sep 21 11:37:14 ubuntu kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-1045-aws root=PARTUUID=5198cbc0-01 ro console=tty1 console=ttyS0 nvme_core.io_timeout=42949>
Sep 21 11:37:14 ubuntu kernel: KERNEL supported cpus:
Sep 21 11:37:14 ubuntu kernel:   Intel GenuineIntel
Sep 21 11:37:14 ubuntu kernel:   AMD AuthenticAMD
Sep 21 11:37:14 ubuntu kernel:   Hygon HygonGenuine
Sep 21 11:37:14 ubuntu kernel:   Centaur CentaurHauls
Sep 21 11:37:14 ubuntu kernel:   zhaoxin   Shanghai  
Sep 21 11:37:14 ubuntu kernel: x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
Sep 21 11:37:14 ubuntu kernel: x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
Sep 21 11:37:14 ubuntu kernel: x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
Sep 21 11:37:14 ubuntu kernel: x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256
Sep 21 11:37:14 ubuntu kernel: x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
Sep 21 11:37:14 ubuntu kernel: BIOS-provided physical RAM map:
Sep 21 11:37:14 ubuntu kernel: BIOS-e820: [mem 0x0000000000000000-0x000000000009dfff] usable
Sep 21 11:37:14 ubuntu kernel: BIOS-e820: [mem 0x000000000009e000-0x000000000009ffff] reserved
Sep 21 11:37:14 ubuntu kernel: BIOS-e820: [mem 0x00000000000e0000-0x00000000000fffff] reserved
Sep 21 11:37:14 ubuntu kernel: BIOS-e820: [mem 0x0000000000100000-0x000000003fffffff] usable
Sep 21 11:37:14 ubuntu kernel: BIOS-e820: [mem 0x00000000fc000000-0x00000000ffffffff] reserved
Sep 21 11:37:14 ubuntu kernel: NX (Execute Disable) protection: active
Sep 21 11:37:14 ubuntu kernel: SMBIOS 2.7 present.
Sep 21 11:37:14 ubuntu kernel: DMI: Xen HVM domU, BIOS 4.2.amazon 08/24/2006
Sep 21 11:37:14 ubuntu kernel: Hypervisor detected: Xen HVM
Sep 21 11:37:14 ubuntu kernel: Xen version 4.2.
Sep 21 11:37:14 ubuntu kernel: Xen Platform PCI: I/O protocol version 1
Sep 21 11:37:14 ubuntu kernel: Netfront and the Xen platform PCI driver have been compiled for this kernel: unplug emulated NICs.
Sep 21 11:37:14 ubuntu kernel: Blkfront and the Xen platform PCI driver have been compiled for this kernel: unplug emulated disks.
                               You might have to change the root device
                               from /dev/hd[a-d] to /dev/xvd[a-d]
                               in your root= kernel command line option
Sep 21 11:37:14 ubuntu kernel: HVMOP_pagetable_dying not supported
Sep 21 11:37:14 ubuntu kernel: tsc: Fast TSC calibration using PIT
Sep 21 11:37:14 ubuntu kernel: tsc: Detected 2400.073 MHz processor
Sep 21 11:37:14 ubuntu kernel: tsc: Detected 2400.074 MHz TSC
Sep 21 11:37:14 ubuntu kernel: e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
Sep 21 11:37:14 ubuntu kernel: e820: remove [mem 0x000a0000-0x000fffff] usable

That’s not Caddy’s logs… I think you ran the wrong command. Run this:

journalctl -u caddy --no-pager | less

Oh, forgive me.
Here:

-- Logs begin at Tue 2021-09-21 11:37:14 UTC, end at Wed 2021-09-22 02:17:01 UTC. --
Sep 21 12:09:19 ip-172-31-91-44 systemd[1]: Starting Caddy...
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: caddy.HomeDir=/var/lib/caddy
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: caddy.AppDataDir=/var/lib/caddy/.local/share/caddy
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: caddy.AppConfigDir=/var/lib/caddy/.config/caddy
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: caddy.ConfigAutosavePath=/var/lib/caddy/.config/caddy/autosave.json
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: caddy.Version=v2.4.5 h1:P1mRs6V2cMcagSPn+NWpD+OEYUYLIf6ecOa48cFGeUg=
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: runtime.GOOS=linux
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: runtime.GOARCH=amd64
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: runtime.Compiler=gc
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: runtime.NumCPU=1
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: runtime.GOMAXPROCS=1
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: runtime.Version=go1.17
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: os.Getwd=/
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: LANG=C.UTF-8
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: NOTIFY_SOCKET=/run/systemd/notify
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: HOME=/var/lib/caddy
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: LOGNAME=caddy
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: USER=caddy
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: INVOCATION_ID=e3625c3a6ef24974b2d6ec6f04fe7e40
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: JOURNAL_STREAM=9:60328
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.4908407,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.4955316,"logger":"admin","msg":"admin endpoint started","address":"tcp/localhost:2019","enforce_origin":false,"origins":["localhost:2019","[::1]:2019","127.0.0.1:2019"]}
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.495976,"logger":"http","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":80}
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.497057,"msg":"autosaved config (load with --resume flag)","file":"/var/lib/caddy/.config/caddy/autosave.json"}
Sep 21 12:09:19 ip-172-31-91-44 systemd[1]: Started Caddy.
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.504026,"msg":"serving initial configuration"}
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.5043025,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000275a40"}
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.50452,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/var/lib/caddy/.local/share/caddy"}
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.5073705,"logger":"tls","msg":"finished cleaning storage units"}
:

Make a request, then check Caddy’s logs again. Those logs are just from Caddy’s startup.

Found I didn’t copy the whole of it:

-- Logs begin at Tue 2021-09-21 11:37:14 UTC, end at Wed 2021-09-22 02:43:33 UTC. --
Sep 21 12:09:19 ip-172-31-91-44 systemd[1]: Starting Caddy...
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: caddy.HomeDir=/var/lib/caddy
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: caddy.AppDataDir=/var/lib/caddy/.local/share/caddy
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: caddy.AppConfigDir=/var/lib/caddy/.config/caddy
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: caddy.ConfigAutosavePath=/var/lib/caddy/.config/caddy/autosave.json
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: caddy.Version=v2.4.5 h1:P1mRs6V2cMcagSPn+NWpD+OEYUYLIf6ecOa48cFGeUg=
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: runtime.GOOS=linux
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: runtime.GOARCH=amd64
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: runtime.Compiler=gc
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: runtime.NumCPU=1
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: runtime.GOMAXPROCS=1
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: runtime.Version=go1.17
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: os.Getwd=/
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: LANG=C.UTF-8
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: NOTIFY_SOCKET=/run/systemd/notify
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: HOME=/var/lib/caddy
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: LOGNAME=caddy
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: USER=caddy
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: INVOCATION_ID=e3625c3a6ef24974b2d6ec6f04fe7e40
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: JOURNAL_STREAM=9:60328
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.4908407,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.4955316,"logger":"admin","msg":"admin endpoint started","address":"tcp/localhost:2019","enforce_origin":false,"origins":["localhost:2019","[::1]:2019","127.0.0.1:2019"]}
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.495976,"logger":"http","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":80}
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.497057,"msg":"autosaved config (load with --resume flag)","file":"/var/lib/caddy/.config/caddy/autosave.json"}
Sep 21 12:09:19 ip-172-31-91-44 systemd[1]: Started Caddy.
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.504026,"msg":"serving initial configuration"}
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.5043025,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000275a40"}
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.50452,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/var/lib/caddy/.local/share/caddy"}
Sep 21 12:09:19 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226159.5073705,"logger":"tls","msg":"finished cleaning storage units"}
Sep 21 12:22:58 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632226978.1243892,"logger":"admin.api","msg":"received request","method":"GET","host":"localhost:2019","uri":"/config/","remote_addr":"127.0.0.1:37818","headers":{"Accept":["*/*"],"User-Agent":["curl/7.68.0"]}}
Sep 21 21:06:52 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632258412.0166447,"logger":"admin.api","msg":"received request","method":"GET","host":"localhost:2019","uri":"/config/","remote_addr":"127.0.0.1:37918","headers":{"Accept":["*/*"],"User-Agent":["curl/7.68.0"]}}
Sep 21 21:14:28 ip-172-31-91-44 systemd[1]: Reloading Caddy.
Sep 21 21:14:28 ip-172-31-91-44 caddy[10368]: {"level":"info","ts":1632258868.1978052,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Sep 21 21:14:28 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632258868.2012842,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/load","remote_addr":"127.0.0.1:37928","headers":{"Accept-Encoding":["gzip"],"Content-Length":["184"],"Content-Type":["application/json"],"Origin":["localhost:2019"],"User-Agent":["Go-http-client/1.1"]}}
Sep 21 21:14:28 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632258868.2023294,"logger":"admin.api","msg":"config is unchanged"}
Sep 21 21:14:28 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632258868.2029002,"logger":"admin.api","msg":"load complete"}
Sep 21 21:14:28 ip-172-31-91-44 systemd[1]: Reloaded Caddy.
Sep 21 21:16:31 ip-172-31-91-44 systemd[1]: Reloading Caddy.
Sep 21 21:16:31 ip-172-31-91-44 caddy[10384]: {"level":"info","ts":1632258991.6880617,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Sep 21 21:16:31 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632258991.6953528,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/load","remote_addr":"127.0.0.1:37930","headers":{"Accept-Encoding":["gzip"],"Content-Length":["184"],"Content-Type":["application/json"],"Origin":["localhost:2019"],"User-Agent":["Go-http-client/1.1"]}}
Sep 21 21:16:31 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632258991.6964521,"logger":"admin.api","msg":"config is unchanged"}
Sep 21 21:16:31 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632258991.697028,"logger":"admin.api","msg":"load complete"}
Sep 21 21:16:31 ip-172-31-91-44 systemd[1]: Reloaded Caddy.
Sep 21 21:24:36 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632259476.8177996,"logger":"admin.api","msg":"received request","method":"GET","host":"localhost:2019","uri":"/config/","remote_addr":"127.0.0.1:37932","headers":{"Accept":["*/*"],"User-Agent":["curl/7.68.0"]}}
Sep 21 21:27:06 ip-172-31-91-44 systemd[1]: Reloading Caddy.
Sep 21 21:27:06 ip-172-31-91-44 caddy[10427]: {"level":"info","ts":1632259626.5851533,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Sep 21 21:27:06 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632259626.588512,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/load","remote_addr":"127.0.0.1:37936","headers":{"Accept-Encoding":["gzip"],"Content-Length":["184"],"Content-Type":["application/json"],"Origin":["localhost:2019"],"User-Agent":["Go-http-client/1.1"]}}
Sep 21 21:27:06 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632259626.5896008,"logger":"admin.api","msg":"config is unchanged"}
Sep 21 21:27:06 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632259626.590204,"logger":"admin.api","msg":"load complete"}
Sep 21 21:27:06 ip-172-31-91-44 systemd[1]: Reloaded Caddy.
Sep 21 21:29:51 ip-172-31-91-44 systemd[1]: Reloading Caddy.
Sep 21 21:29:51 ip-172-31-91-44 caddy[10457]: {"level":"info","ts":1632259791.796795,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Sep 21 21:29:51 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632259791.8002868,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/load","remote_addr":"127.0.0.1:37938","headers":{"Accept-Encoding":["gzip"],"Content-Length":["184"],"Content-Type":["application/json"],"Origin":["localhost:2019"],"User-Agent":["Go-http-client/1.1"]}}
Sep 21 21:29:51 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632259791.8013632,"logger":"admin.api","msg":"config is unchanged"}
Sep 21 21:29:51 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632259791.801944,"logger":"admin.api","msg":"load complete"}
Sep 21 21:29:51 ip-172-31-91-44 systemd[1]: Reloaded Caddy.
Sep 21 22:02:41 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632261761.238198,"logger":"admin.api","msg":"received request","method":"GET","host":"localhost:2019","uri":"/config/","remote_addr":"127.0.0.1:37940","headers":{"Accept":["*/*"],"User-Agent":["curl/7.68.0"]}}
Sep 21 22:35:56 ip-172-31-91-44 systemd[1]: Reloading Caddy.
Sep 21 22:35:56 ip-172-31-91-44 caddy[11817]: {"level":"info","ts":1632263756.2491863,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Sep 21 22:35:56 ip-172-31-91-44 caddy[11817]: {"level":"warn","ts":1632263756.252123,"msg":"input is not formatted with 'caddy fmt'","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":10}
Sep 21 22:35:56 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632263756.2533295,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/load","remote_addr":"127.0.0.1:38014","headers":{"Accept-Encoding":["gzip"],"Content-Length":["461"],"Content-Type":["application/json"],"Origin":["localhost:2019"],"User-Agent":["Go-http-client/1.1"]}}
Sep 21 22:35:56 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632263756.254717,"logger":"admin","msg":"admin endpoint started","address":"tcp/localhost:2019","enforce_origin":false,"origins":["localhost:2019","[::1]:2019","127.0.0.1:2019"]}
Sep 21 22:35:56 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632263756.255121,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
Sep 21 22:35:56 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632263756.2617388,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc000290700"}
Sep 21 22:35:56 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632263756.2630453,"logger":"tls.cache.maintenance","msg":"stopped background certificate maintenance","cache":"0xc000275a40"}
Sep 21 22:35:56 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632263756.2633018,"msg":"autosaved config (load with --resume flag)","file":"/var/lib/caddy/.config/caddy/autosave.json"}
Sep 21 22:35:56 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632263756.2640383,"logger":"admin.api","msg":"load complete"}
Sep 21 22:35:56 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632263756.265603,"logger":"admin","msg":"stopped previous server","address":"tcp/localhost:2019"}
Sep 21 22:35:56 ip-172-31-91-44 systemd[1]: Reloaded Caddy.
Sep 21 22:36:02 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632263762.9780185,"logger":"admin.api","msg":"received request","method":"GET","host":"localhost:2019","uri":"/config/","remote_addr":"127.0.0.1:38016","headers":{"Accept":["*/*"],"User-Agent":["curl/7.68.0"]}}
Sep 21 23:00:30 ip-172-31-91-44 systemd[1]: Reloading Caddy.
Sep 21 23:00:30 ip-172-31-91-44 caddy[11892]: {"level":"info","ts":1632265230.1086833,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Sep 21 23:00:30 ip-172-31-91-44 caddy[11892]: {"level":"warn","ts":1632265230.111226,"msg":"input is not formatted with 'caddy fmt'","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":10}
Sep 21 23:00:30 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632265230.1131165,"logger":"admin.api","msg":"received request","method":"POST","host":"localhost:2019","uri":"/load","remote_addr":"127.0.0.1:38082","headers":{"Accept-Encoding":["gzip"],"Content-Length":["461"],"Content-Type":["application/json"],"Origin":["localhost:2019"],"User-Agent":["Go-http-client/1.1"]}}
Sep 21 23:00:30 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632265230.1142619,"logger":"admin.api","msg":"config is unchanged"}
Sep 21 23:00:30 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632265230.114868,"logger":"admin.api","msg":"load complete"}
Sep 21 23:00:30 ip-172-31-91-44 systemd[1]: Reloaded Caddy.
Sep 21 23:09:37 ip-172-31-91-44 caddy[8819]: {"level":"info","ts":1632265777.1319025,"logger":"admin.api","msg":"received request","method":"GET","host":"localhost:2019","uri":"/config/","remote_addr":"127.0.0.1:38108","headers":{"Accept":["*/*"],"User-Agent":["curl/7.68.0"]}}



This is all of the logs.

As far as I can tell, Caddy never actually received a request other than reload API calls. Are you sure your DNS is properly set up to route requests to your server’s IP address? Do you have ports 80 and 443 forwarded and open?

Yes, I have both of those open on the firewall. Not sure what went wrong. I would go ahead to add:

http:// {
  	redir https://{host}{uri}
}

But that doesn’t seem to make any difference. Reverting the Caddyfile to the original state seems to work. It displays the "congratulation’ page. :sob:

Not really sure what went wrong but everything works fine on Digital ocean droplet but not on AWS EC2.

Thank you very much for your help and support @francislavoie

Caddy does HTTP->HTTPS redirects automatically. No need to add that.

:thinking: I doubt it’s the actual VPS provider that caused the issue, it was probably just the fact that you did a fresh install that resolved it.

Glad it works, I suppose :+1:

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