My caddy config cant obtain certificates with systemctl

/usr/bin/caddy run --config /etc/caddy/Caddyfile.json : tls.obtain certificate obtained successfully

then I remove certificate file and run systemctl restart caddy it wont obtain certificate

then again: /usr/bin/caddy run --config /etc/caddy/Caddyfile.json : tls.obtain certificate obtained successfully

I dont know why.

caddy config:

{
    "admin": {"disabled": true},
    "apps": {
		"tls": {"certificates": {"automate": ["xxxx.xxx.xxx"]},"automation": {"policies": [{"issuer": {"challenges": {"tls-alpn": {"disabled": true}},"module": "acme"},"subjects": ["xxxx.xxx.xxx"]}]}},
        "http": {
            "servers": {
                "srv0": {
                    "listen": [":80"],
                    "routes": [
                        {
                            "match": [{"host": ["xxxx.xxx.xxx"]}],
                            "handle": [{"handler": "subroute","routes": [{"handle": [{"handler": "static_response","headers": {"Location": ["https://{http.request.host}{http.request.uri}"]},"status_code": 301}]}]}],
                            "terminal": true
                        }
                    ]
                },
                "srv1": {
                    "listen": ["127.0.0.1:50080"],
                    "routes": 
                    [
                        {
                            "match": [{"host": ["xxxx.xxx.xxx"]}],
                            "handle": [{
                                "handler": "file_server",
                                "root": "/usr/share/caddy"
                            }],
                            "terminal": true
                        }
                    ],
                    "automatic_https": {
                        "disable": true 
                    },
                    "allow_h2c": true
                }
            }
        }
    }
}

I am trying to use caddy only with port 80 to get certificates for xray

Please fill out the help thread template, we’re missing key information here, like your logs, version, OS, etc.

1 Like

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