Caddy Reboot Not Forcing Front-end Page Refresh as Expected

1. The problem I’m having:

TLDR: After updating my basic_auth password, unless page is refreshed and client reauthenticated, adding/deleting routes from caddy config behavior changes. Functionality still works, but no longer is a page refresh forced.

I have designed a process that allows me to mount shared drives to my server, and add them as routes to my caddy instance. In my testing, no matter what - this forced a reboot of the caddy instance, and therefore a refresh of my browser because the original connection was terminated. I’ve come to get along with this behavior, and as such I display a loading page until the page is refresh, and upon refresh the state for the page returns to the default isLoading=false. I like this behavior. I have been working today on an interface from the front-end to update the basic_auth password applied to my front-end route in the caddy instance. I have this working as well. What I have noticed though, is that even though this seems to log that my caddy instance is reloaded, this does not force a page refresh. While this in itself is not a bad thing, until I have refreshed the browser and reauthenticated, my frontend can still make changes to the caddy configuration - yet the previous behavior for adding/deleting routes forcing a refresh is gone. It no longer forces a refresh, causing my frontend to hangup on the loading screen until the user performs a manual refresh.

2. Error messages and/or full log output:

In the below log - I change the password and I add a route for a file_server browse to a mounted drive. Both requests result in “admin stopped previous server”… and neither forced a page refresh on the frontend.

parallels@ubuntu-linux-2404:~/coding/edgeCraftStudio/heimerdinger$ sudo caddy run
[sudo] password for parallels: 
2025/02/20 16:55:24.606 INFO    using adjacent Caddyfile
2025/02/20 16:55:24.607 INFO    adapted config to JSON  {"adapter": "caddyfile"}
2025/02/20 16:55:24.607 WARN    Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies    {"adapter": "caddyfile", "file": "Caddyfile", "line": 6}
2025/02/20 16:55:24.609 INFO    admin   admin endpoint started  {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2025/02/20 16:55:24.609 INFO    http.auto_https 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}
2025/02/20 16:55:24.609 INFO    http.auto_https enabling automatic HTTP->HTTPS redirects        {"server_name": "srv0"}
2025/02/20 16:55:24.609 INFO    tls.cache.maintenance   started background certificate maintenance      {"cache": "0x40000fd700"}
2025/02/20 16:55:24.611 INFO    http    enabling HTTP/3 listener        {"addr": ":443"}
2025/02/20 16:55:24.611 INFO    http.log        server running  {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2025/02/20 16:55:24.611 WARN    http    HTTP/2 skipped because it requires TLS  {"network": "tcp", "addr": ":80"}
2025/02/20 16:55:24.611 WARN    http    HTTP/3 skipped because it requires TLS  {"network": "tcp", "addr": ":80"}
2025/02/20 16:55:24.611 INFO    http.log        server running  {"name": "remaining_auto_https_redirects", "protocols": ["h1", "h2", "h3"]}
2025/02/20 16:55:24.611 INFO    http    enabling automatic TLS certificate management   {"domains": ["heimerdinger.ecs-iot.com"]}
2025/02/20 16:55:24.612 INFO    autosaved config (load with --resume flag)      {"file": "/root/.config/caddy/autosave.json"}
2025/02/20 16:55:24.612 INFO    serving initial configuration
2025/02/20 16:55:24.614 INFO    tls     storage cleaning happened too recently; skipping for now        {"storage": "FileStorage:/root/.local/share/caddy", "instance": "9cbe4f7b-7b5c-4143-96d6-abff06b06317", "try_again": "2025/02/21 16:55:24.614", "try_again_in": 86399.99999975}
2025/02/20 16:55:24.614 INFO    tls     finished cleaning storage units
2025/02/20 16:56:00.095 INFO    admin.api       received request        {"method": "GET", "host": "localhost:2019", "uri": "/config/apps/http/servers/srv0/routes/0/handle/0/routes", "remote_ip": "127.0.0.1", "remote_port": "56560", "headers": {"Accept":["*/*"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["*"],"Connection":["keep-alive"],"Content-Type":["application/json"],"Sec-Fetch-Mode":["cors"],"User-Agent":["node"]}}
2025/02/20 16:56:01.317 INFO    admin.api       received request        {"method": "PATCH", "host": "localhost:2019", "uri": "/config/apps/http/servers/srv0/routes/0/handle/0/routes/1/handle/0/routes/0/handle/1/providers/http_basic/accounts/0/password", "remote_ip": "127.0.0.1", "remote_port": "56560", "headers": {"Accept":["*/*"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["*"],"Connection":["keep-alive"],"Content-Length":["64"],"Content-Type":["application/json"],"Sec-Fetch-Mode":["cors"],"User-Agent":["node"]}}
2025/02/20 16:56:01.320 INFO    admin   admin endpoint started  {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2025/02/20 16:56:01.321 INFO    http.auto_https 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}
2025/02/20 16:56:01.322 INFO    http.auto_https enabling automatic HTTP->HTTPS redirects        {"server_name": "srv0"}
2025/02/20 16:56:01.323 INFO    http    enabling HTTP/3 listener        {"addr": ":443"}
2025/02/20 16:56:01.323 INFO    http.log        server running  {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2025/02/20 16:56:01.324 WARN    http    HTTP/2 skipped because it requires TLS  {"network": "tcp", "addr": ":80"}
2025/02/20 16:56:01.324 WARN    http    HTTP/3 skipped because it requires TLS  {"network": "tcp", "addr": ":80"}
2025/02/20 16:56:01.324 INFO    http.log        server running  {"name": "remaining_auto_https_redirects", "protocols": ["h1", "h2", "h3"]}
2025/02/20 16:56:01.325 INFO    http    enabling automatic TLS certificate management   {"domains": ["heimerdinger.ecs-iot.com"]}
2025/02/20 16:56:01.325 INFO    http    servers shutting down with eternal grace period
2025/02/20 16:56:01.326 INFO    autosaved config (load with --resume flag)      {"file": "/root/.config/caddy/autosave.json"}
2025/02/20 16:56:01.330 INFO    admin   stopped previous server {"address": "localhost:2019"}
2025/02/20 16:56:19.475 INFO    admin.api       received request        {"method": "GET", "host": "localhost:2019", "uri": "/config/apps/http/servers/srv0/routes/0/handle/0/routes/", "remote_ip": "127.0.0.1", "remote_port": "34420", "headers": {"Accept":["*/*"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["*"],"Connection":["keep-alive"],"Content-Type":["application/json"],"Sec-Fetch-Mode":["cors"],"User-Agent":["node"]}}
2025/02/20 16:56:19.491 INFO    admin.api       received request        {"method": "PUT", "host": "localhost:2019", "uri": "/config/apps/http/servers/srv0/routes/0/handle/0/routes/0", "remote_ip": "127.0.0.1", "remote_port": "34424", "headers": {"Accept":["*/*"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["*"],"Connection":["keep-alive"],"Content-Length":["299"],"Content-Type":["application/json"],"Sec-Fetch-Mode":["cors"],"User-Agent":["node"]}}
2025/02/20 16:56:19.502 INFO    admin   admin endpoint started  {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2025/02/20 16:56:19.512 INFO    http.auto_https 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}
2025/02/20 16:56:19.514 INFO    http.auto_https enabling automatic HTTP->HTTPS redirects        {"server_name": "srv0"}
2025/02/20 16:56:19.538 WARN    http    HTTP/2 skipped because it requires TLS  {"network": "tcp", "addr": ":80"}
2025/02/20 16:56:19.540 WARN    http    HTTP/3 skipped because it requires TLS  {"network": "tcp", "addr": ":80"}
2025/02/20 16:56:19.541 INFO    http.log        server running  {"name": "remaining_auto_https_redirects", "protocols": ["h1", "h2", "h3"]}
2025/02/20 16:56:19.545 INFO    http    enabling HTTP/3 listener        {"addr": ":443"}
2025/02/20 16:56:19.547 INFO    http.log        server running  {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2025/02/20 16:56:19.547 INFO    http    enabling automatic TLS certificate management   {"domains": ["heimerdinger.ecs-iot.com"]}
2025/02/20 16:56:19.550 INFO    http    servers shutting down with eternal grace period
2025/02/20 16:56:19.566 INFO    autosaved config (load with --resume flag)      {"file": "/root/.config/caddy/autosave.json"}
2025/02/20 16:56:19.579 INFO    admin   stopped previous server {"address": "localhost:2019"}

Below is me adding a route for a shared drive prior to updating the password. This request did force a page refresh on the frontend.

2025/02/20 17:00:17.397 INFO    admin.api       received request        {"method": "GET", "host": "localhost:2019", "uri": "/config/apps/http/servers/srv0/routes/0/handle/0/routes/", "remote_ip": "127.0.0.1", "remote_port": "47530", "headers": {"Accept":["*/*"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["*"],"Connection":["keep-alive"],"Content-Type":["application/json"],"Sec-Fetch-Mode":["cors"],"User-Agent":["node"]}}
2025/02/20 17:00:17.423 INFO    admin.api       received request        {"method": "PUT", "host": "localhost:2019", "uri": "/config/apps/http/servers/srv0/routes/0/handle/0/routes/0", "remote_ip": "127.0.0.1", "remote_port": "47534", "headers": {"Accept":["*/*"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["*"],"Connection":["keep-alive"],"Content-Length":["293"],"Content-Type":["application/json"],"Sec-Fetch-Mode":["cors"],"User-Agent":["node"]}}
2025/02/20 17:00:17.429 INFO    admin   admin endpoint started  {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2025/02/20 17:00:17.431 INFO    http.auto_https 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}
2025/02/20 17:00:17.431 INFO    http.auto_https enabling automatic HTTP->HTTPS redirects        {"server_name": "srv0"}
2025/02/20 17:00:17.437 INFO    http    enabling HTTP/3 listener        {"addr": ":443"}
2025/02/20 17:00:17.438 INFO    http.log        server running  {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2025/02/20 17:00:17.438 WARN    http    HTTP/2 skipped because it requires TLS  {"network": "tcp", "addr": ":80"}
2025/02/20 17:00:17.438 WARN    http    HTTP/3 skipped because it requires TLS  {"network": "tcp", "addr": ":80"}
2025/02/20 17:00:17.438 INFO    http.log        server running  {"name": "remaining_auto_https_redirects", "protocols": ["h1", "h2", "h3"]}
2025/02/20 17:00:17.438 INFO    http    enabling automatic TLS certificate management   {"domains": ["heimerdinger.ecs-iot.com"]}
2025/02/20 17:00:17.439 INFO    http    servers shutting down with eternal grace period
2025/02/20 17:00:17.441 INFO    autosaved config (load with --resume flag)      {"file": "/root/.config/caddy/autosave.json"}
2025/02/20 17:00:17.450 INFO    admin   stopped previous server {"address": "localhost:2019"}

3. Caddy version:

v2.9.1

4. How I installed and ran Caddy:

I followed the Ubuntu installation instructions from the caddy website.
I am also using a custom build to support cloudflare dns resolution from xcaddy.
GitHub - caddy-dns/cloudflare: Caddy module: dns.providers.cloudflare.

a. System environment:

Running an ubuntu 24.04 vm via Parallels.

b. Command:

caddy adapt
sudo caddy run

d. My complete Caddy config:

heimerdinger.ecs-iot.com {
	handle_path /api/* {
		reverse_proxy :5000
	}
	handle /* {
    header {
      Connection "close"
    }
		basic_auth {
			admin <password>
		}
		reverse_proxy :5173
	}
	tls {
		dns cloudflare <token>
	}
}

This is resolved - the issue ended up being related to vite dev server’s hot reloading. Not a caddy issue.

1 Like