I'm running Debian 12 and configuring a cloudflared tunnel. My config.yml is stored outside my home directory, while the XYZ.json certificate file is somewhere under my home directory, such as /home/username/.cloudflare/. The tunnel service reports that the JSON file does not exist, so I suspect the path syntax is wrong. What is the correct way to reference a file located in another directory, and how do permissions or running the service as root affect the path?
1 Answer
Use the file’s absolute path rather than a relative path or a path beginning with ~. For example: /home/username/.cloudflare/XYZ.json. Add that path to the appropriate certificate or credentials-file setting in config.yml. Also make sure the account running cloudflared can traverse the directories and read the JSON file. If the service runs as root, it will still need the exact absolute path, and root’s home directory is /root—not your normal user’s home directory.

The JSON file does not have to be beside config.yml. The important parts are using the correct full path and ensuring the cloudflared service user has permission to read it.