Caddy

Restart the service on failure

This will automatically restart the server after 5 seconds if the exit code when crashing was not 1.

To edit the below file, run

sudo systemctl edit caddy
[Service]
RestartPreventExitStatus=1
Restart=on-failure
RestartSec=5s

Redirect from www to root

Add www

example.com {
    redir https://www.{host}{uri}
}

www.example.com {
}

Remove www

www.example.com {
    redir https://example.com{uri}
}

example.com {
}