Running cloudflared as service

I have previously configured cloudflared and it works successfully on another servere I am setting up cloudflared on a new server and have so far done the following, which initially worked;

  1. Installed fresh download of cloudlfared in /usr/local/bin
  2. Created config.yml in /etc/cloudflared with the following content, copied from previous working install,
hostname: {subdomain.cloudflarehosted.domain}
url: {local hosted url root eg. HTTP://127.0.0.1:80/}
logfile: {local logfile path+filename}
autoupdate-freq: 10m
  1. Running cloudflared tunnel login and cloudflared tunnel create {tunnelname} under root both work and create the required files. With the config.yml file running cloudflared tunnel also works correctly, puts the website online, the subdomain {subdomain.cloudflarehosted.domain} exists and there is no error. Traffic routing works, the website works.
  2. Debugging the output of the previous command advises we are running a link in legacy mode and gives a link for migration to Running cloudflares service install does not work. The migration document is suitable for a loadbalancer migration.

Having read the documentation extensively I believe the answer is for a dns route (non-loadbalancer deployment), the answer is to run an ad-hoc tunnel to enable the current AAAA entry configuration and make use of ~/.config/autostart/cloudflared.desktop. Configuration is already available through ~/.cloudflared/config.yml just be cautioned not to use sudo for the creation of any setup.

Comments?

It sounds like you’re trying to use a legacy format for your config file instead of an Ingress rules type file. Based on your sample config file, I think a proper config file will fix this.

https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/configuration/config

And then your DNS entry for subdomain.cloudflarehosted.domain should be a CNAME that points to: TUNNEL_ID.cfargotunnel.com

I have built a new configuration file but now, running from ad-hoc, the cloudflared runs but my website says Error 1033.

Now I have changed it back. I will just run ad-hoc on autostart until a proper solution is posted.

I cannot use cloudflared tunnel route dns {tunnelname} {hostnamename} it says the DNS entry already exists. The new config.yml specifies the domain name hostname: in the new format.

Actually, I am trying to avoid that cname solution, I already use cname to point to AAAA record.

So far I am working with this script and will configure cron, I could not get another example to work on Raspberry Pi using pgrep,

#!/bin/bash
if [[ ! -n $(ps -ae | grep cloudflared) ]]; then
        cloudflared tunnel &
fi

That’s pretty much how I started with as a legacy configuration, then decided I’d be better off with Ingress rules. But that’s on Ubuntu. I’ve not tried it on a Pi…yes. It’s next on my list.

Eventually, I made use of Supervisor to solve this problem.

1 Like