Caddy2 Cloudflare-DNS Implimentation Windows Native

Your error references a specific line in your Caddyfile (line 40). Unexpected EOF generally means the file ends while the parser is still expecting more arguments (unfinished site block? unfinished directive?).

If you post your current unredacted Caddyfile along with the error you’re getting with it, we can point to the specific problem.

aaah thank you much appreciated. fixed that but now im getting an error with the reverse proxy ive triple checked the code is most defintly correct.

c:\Caddy2>caddy reload caddyfile
2020/06/08 06:28:59.543 ←[34mINFO←[0m   using adjacent Caddyfile
reload: adapting config using caddyfile: parsing caddyfile tokens for 'log': Caddyfile:9 - Error during parsing: unrecognized subdirective: reverse_proxy

Probably incorrect bracing.

Somehow, the Caddyfile parser has been bamboozled into thinking you’ve got a reverse_proxy as a subdirective of another directive.

yeah i think i fixed it on line 9 i didnt use the } to close the log statement

So were almost there now i get an api token is missing error.
this is the correct way to register the api token. and no i didnt use the global api token. i made a specific one with zone.zone and zone.dns.

        reverse_proxy 127.0.0.1:8096
        tls {
            dns cloudflare {cloudflare api key}
        }

and yes i realized i accidently posted my api key ive already rolled it

I only know this because I can see the edit history, but it seems like you’ve literally encapsulated your token in braces.

There should be no braces surrounding your API token.

okay so it should be like this

        reverse_proxy 127.0.0.1:8096
        tls {
            dns cloudflare cloudflare api key
        }

okay im finally off the stupid syntax errros. now when i do command caddy reload caddyfile
i get this error

2020/06/08 07:15:35.878 ←[34mINFO←[0m   using adjacent Caddyfile
reload: sending configuration to instance: performing request: Post "http://localhost:2019/load": dial tcp [::1]:2019: connectex: No connection could be made because the target machine actively refused it.

i dont even know why its trying to connect to port 2019 thats no where in my config

By default, Caddy listens on localhost:2019 for its config API. It’s how config reloads are done - it sends an HTTP request to that endpoint to push the new config.

so i do i push the new localhost:2019 to localhost:443 if im trying to run cloudflare and SSL
I’m sorry im a little confused on how to apply this with my caddy config. Could you possibly give me an example that would pertain to me?
i also thought this wasnt needed as im using a caddyfile instead of a json file
UPDATE #1:
Got it i had to type command caddy start
instead of
caddy reload caddyfile

Just to be clear, Caddy always uses JSON as its configuration language. The Caddyfile is just syntax sugar to make it easier to write your config, but it’s parsed and adapted to JSON.

Caddy uses the config API internally to implement graceful reloads. It’s the most portable way to do this, because Caddy needs to run on all OSes and running an HTTP server is something that works everywhere.

If Caddy wasn’t running in the first place, then yes, reload won’t work. That wasn’t clear from your post. You need to run it before you can reload its configuration! Once it’s running, the recommended way to change the config is to use caddy reload to push the new config and do a zero downtime reload.

2 Likes

I must be blind. Where in the screenshot does it say --output GOOS=windows??

1 Like

Right here

Sorry, but, where?? Circle it.

1 Like

If I did caddy stop
Caddy start
Instead of caddy reload
Would that caused a 522 error. Because thats where I’m stuck atm

I can’t rn im not near a computer sorry. I’ll be able to around 3pm. When I get back to my house.

HTTP status code 522 is a non-standard status returned from Cloudflare.

1 Like

ive checkd all my cloudflare settings and im 99% sure my settings are setup correctly. the errror tells me the origin certificate is not registering. Is that becuase i have to set the the enviromental variables or would that not matter. ie.
https://go-acme.github.io/lego/dns/cloudflare/

if so would i implement it like in version 1

setlocal
set CLOUDFLARE_EMAIL=ittechnut@hotmail.com
set CLOUDFLARE_API_KEY=bb90be4bf96e600a7ea7f4d5dee287ba3e542
start caddy run

thats in a .bat for windows
also is the clouflare api key going to be an api or global key

Update #1:
I got it working i had to port forward my ports for the domain because my upnp was not picking up the ports. its 100% resolved thank you to everyone who helped.

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