Repository: caddyserver/caddy (language: go)

Issue:
Caddy Keeps Reloading Config in v2.7.5 due to skip_host order changing
Had to disable `--watch` because caddy suddenly started to continuously reload the config.

Further investigation shown this is due to the order of `skip_host` continuously changing, the first two hosts in the following code.

```
{
    "apps": {
        "http": {
            "http_port": 80,
            "https_port": 443,
            "servers": {
                "srv0": {
                    "listen": [
                        ":443"
                    ],
                    "logs": {
                        "logger_names": {
                            "*.mydomain.biz": "",
                            "mydomain.biz": "",
                            "mysite.mydomain.biz": "log0"
                        },
                        "skip_hosts": [
                            "wpad.mydomain.biz",
                            "wpad.lan.mydomain.biz",
                            "www.lan.mydomain.biz",
```

This happen in a custom image based on `caddy:2.7.5-builder-alpine` but `--with github.com/caddy-dns/cloudflare` and `--with github.com/caddyserver/ntlm-transport`.




Discussion / hints:
Please share your actual config which reproduces this.

Fix patch:
diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go
index c82d92efc62..cb3095a16ac 100644
--- a/caddyconfig/httpcaddyfile/httptype.go
+++ b/caddyconfig/httpcaddyfile/httptype.go
@@ -820,6 +820,11 @@ func (st *ServerType) serversFromPairings(
 			}
 		}
 
+		// sort for deterministic JSON output
+		if srv.Logs != nil {
+			slices.Sort(srv.Logs.SkipHosts)
+		}
+
 		// a server cannot (natively) serve both HTTP and HTTPS at the
 		// same time, so make sure the configuration isn't in conflict
 		err := detectConflictingSchemes(srv, p.serverBlocks, options)


Test patch:
diff --git a/caddytest/integration/caddyfile_adapt/log_skip_hosts.txt b/caddytest/integration/caddyfile_adapt/log_skip_hosts.txt
index 25e4bd1c206..8fdd5715612 100644
--- a/caddytest/integration/caddyfile_adapt/log_skip_hosts.txt
+++ b/caddytest/integration/caddyfile_adapt/log_skip_hosts.txt
@@ -66,9 +66,9 @@ example.com {
 							"one.example.com": ""
 						},
 						"skip_hosts": [
+							"example.com",
 							"three.example.com",
-							"two.example.com",
-							"example.com"
+							"two.example.com"
 						]
 					}
 				}