Auto apply config after restart on WIndows

1. The problem I’m having:

When my machine restarts, It does not load the previous config.

2. Error messages and/or full log output:

no errors.

3. Caddy version:

v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=

4. How I installed and ran Caddy:

Installed as windows service using documentation on site. All interaction is down through REST API.

a. System environment:

Windows 11

b. Command:

I do not use commandline.

c. Service/unit/compose file:

n/a

d. My complete Caddy config:

{
    "apps": {
        "http": {
            "http_port": 80,
            "https_port": 443,
            "servers": {
                "primary": {
                    "automatic_https": {
                        "disable": false
                    },
                    "listen": [
                        ":443"
                    ],
                    "routes": [
                        {
                            "handle": [
                                {
                                    "handler": "reverse_proxy",
                                    "upstreams": [
                                        {
                                            "dial": "localhost:1323"
                                        }
                                    ]
                                }
                            ],
                            "match": [
                                {
                                    "host": [
                                        "fnasupload.atr-systems.com"
                                    ]
                                }
                            ]
                        },
						{
                            "handle": [
                                {
                                    "handler": "reverse_proxy",
                                    "upstreams": [
                                        {
                                            "dial": "192.168.1.61:8080"
                                        }
                                    ]
                                }
                            ],
                            "match": [
                                {
                                    "host": [
                                        "www.imnotscott.com"
                                    ]
                                }
                            ]
                        },
                        {
                            "handle": [
                                {
                                    "handler": "reverse_proxy",
                                    "upstreams": [
                                        {
                                            "dial": "localhost:3000"
                                        }
                                    ]
                                }
                            ],
                            "match": [
                                {
                                    "host": [
                                        "ai.imnotscott.com"
                                    ]
                                }
                            ]
                        }
                    ]
                }

            }
        }
    }
}

5. Links to relevant resources:

Are you running Caddy with the --resume flag? You’re meant to, if you’re using the API. Command Line — Caddy Documentation

You can remove these, restating the defaults is not useful.

You can remove this as well, setting disable to false doesn’t do anything.

Thanks. I had to add that to the end of the following command
sc.exe create caddy start= auto binPath= “YOURPATH\caddy.exe run --resume”

1 Like