Thanks for making this available. Great tool indeed.
I must say I was quite lost following the somewhat disjointed documentation on your Reference site. Fortunately I found these two articles that actually made it easier (please consider doing something similar in the Reference area): https://docs.pi-hole.net/guides/dns-over-https/#configuring-dns-over-https
Anyway… I have run into an issue, perhaps you can point me in the right direction. It looks like the daemon is not capable of running both the Tunnel and the DoH resolver at the same time. When I run the command cloudflared alone at the CLI, it runs both services just fine, getting the settings for both services from the same /etc/cloudflared/config.yml. I can dig DNS queries and access the hello-world page I setup for my domain without a problem. This tells me my config.yml is setup correctly, according to the instructions.
But when I try running the daemon as a service (as per the instructions), it just produces an immediate misconfiguration error and never starts. My guess is I need to put the Tunnel related settings in a different file where the daemon is probably looking. That is not clear at all in the instructions. But the fact that both services start just fine when NOT running the daemon, tells me there is probably a bug in the code. Any guidance will be much appreciated.
In the service file, do you point to the correct config file? It may not be the same you have modified as the normal start looks in the current directory as well.
Yes, I think so. The /etc/cloudflared folder contains both the cert.pem and config.yml files. If I stop the service and just run “cloudflared” without any parameters, I can see all my settings being initialized, for both the Cloudflare Tunnel and the DNS Proxy, and they both work but in console mode. When I stop the console and run the command to start the service, it complains about the Cloudflare Tunnel stuff. If I comment out either the Argo stuff, or the DNS Proxy stuff, both work just fine as a service independently, but not together. Does that make sense?
Here is my config (I just replaced my real domain with mydomain.com):
Here is what comes up when I just run “cloudflared” without parameters:
pi@raspberrypi-2:/etc/cloudflared $ cloudflared
INFO[0000] Version 2020.5.1
INFO[0000] GOOS: linux, GOVersion: go1.12.7, GoArch: arm
INFO[0000] Flags hello-world=true hostname=mydomain.com proxy-dns=true proxy-dns-port=5333 proxy-dns-upstream=“https://1.1.1.1/dns-query, https://1.0.0.1/dns-query” url=“https://localhost:8000”
INFO[0000] Adding DNS upstream url=“https://1.1.1.1/dns-query”
INFO[0000] Adding DNS upstream url=“https://1.0.0.1/dns-query”
INFO[0000] Starting DNS over HTTPS proxy server addr=“dns://localhost:5333”
INFO[0000] Starting metrics server addr=“127.0.0.1:45761/metrics”
INFO[0000] cloudflared will not automatically update when run from the shell. To enable auto-updates, run cloudflared as a service: https://developers.cloudflare.com/argo-tunnel/reference/service/
INFO[0000] hello-world set
INFO[0000] Starting Hello World server at 127.0.0.1:37645
INFO[0000] Proxying tunnel requests to https://127.0.0.1:37645
INFO[0000] Connected to ORD connectionID=0
I didn’t include the HA connection IDs for privacy, but there are no errors in the code that goes below that.
When I install the service I get one error. Maybe that’s where the problem lies?
pi@raspberrypi-2:/etc/cloudflared $ sudo cloudflared service install
INFO[0000] Using Systemd
ERRO[0000] systemctl: Created symlink /etc/systemd/system/multi-user.target.wants/cloudflared.service → /etc/systemd/system/cloudflared.service.
INFO[0000] systemctl daemon-reload
Then trying to start the service fails:
pi@raspberrypi-2:/etc/cloudflared $ sudo systemctl start cloudflared
Job for cloudflared.service failed because the control process exited with error code.
See “systemctl status cloudflared.service” and “journalctl -xe” for details.
But if I remove either the 3 lines related to the Argo Tunnel, or the 5 lines related to the DNS Proxy, then it works for those services independently, but not together. That’s where I’m stuck.
I take that last statement back… If I just leave the Argo Tunnel code in, it won’t start either. Same error. Only the DNS Proxy code is observed from that config file. The only way I have been able to get the Argo Tunnel to work is from the command line, but not as a service.
I think you are correct, and I think that may be best also. I am not sure how to go about that. Am I able to run them both on the same device, in this case a Raspberry Pi? Do I need to register two separate services from the same installation (file location)? Or do I need to install in a different folder? And, where do I place the config.yml for the Argo Tunnel?
Sorry about all the noob questions, but I’m having a heck of a time getting this to work. I was able to get NextDNS DoH proxy to work with a single install command, so I got spoiled there.
Do I need to re-enable the service using the same old name, and once the file is created, then do the renaming?
If I try running sudo cloudflared service install, it now fails, telling me I should have two files in the /etc/cloudflared folder, one named cert.pem (which is there), and one named config.yml (which no longer exists since I renamed the two copies as suggested).