Argo Tunnel as a service

Hi,

I’m trying to setup an Argo Tunnel as a service from a MacOS device. I’m running the latest cloudflared version (2021.2.1).

This is the config I’m having:

tunnel: xxxxxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxx
credentials-file: /etc/cloudflared/xxxxxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxx.json

ingress:
  - hostname: test.mydomain.com
    service: hello_world
  - service: http_status:404

If I’m running cloudflared tunnel run, the tunnel is setup correctly and without problems.
When I run the tunnel however by cloudflared service install, I get the following error:

Use `cloudflared tunnel run` to start tunnel xxxxxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxxxx

It’s also very strange as I’ve found that you can also run the tunnel in --legacy mode. This is however the error I’m getting when I’m trying to run it in legacy mode:

$ sudo cloudflared service install --legacy
Incorrect Usage: flag provided but not defined: -legacy

NAME:
   cloudflared service install - Install Argo Tunnel as an user launch agent

USAGE:
   cloudflared service install [command options] [arguments...]

OPTIONS:
   --help, -h  show help (default: false)

Any idea how I can solve this?

Thanks a lot in advance!
Cadish

Hello @Cadish ,

In MacOS, the service installation will create a plist file somewhere in /Users/<USER>/Library/LaunchAgents/com.cloudflare.cloudflared.plist.
If you edit that file, you can properly configure the command used to launch cloudflared. E.g.:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
        <dict>
                <key>Label</key>
                <string>com.cloudflare.cloudflared</string>
                <key>ProgramArguments</key>
                <array>
                        <string>/usr/local/bin/cloudflared</string>
                        <string>tunnel</string>
                        <string>--config</string>
                        <string>/Users/<USER>/Downloads/config.yaml</string>
                        <string>run</string>
                </array>
                <key>RunAtLoad</key>
                <true/>
                <key>StandardOutPath</key>
                <string>/Users/<USER>/Library/Logs/com.cloudflare.cloudflared.out.log</string>
                <key>StandardErrorPath</key>
                <string>/Users/<USER>/Library/Logs/com.cloudflare.cloudflared.err.log</string>
                <key>KeepAlive</key>
                <dict>
                        <key>SuccessfulExit</key>
                        <false/>
                </dict>
                <key>ThrottleInterval</key>
                <integer>5</integer>
        </dict>
</plist>

And then just do:

launchctl unload /Users/<USER>/Library/LaunchAgents/com.cloudflare.cloudflared.plist

(to stop the currently running cloudflared)

And:

launchctl load /Users/<USER>/Library/LaunchAgents/com.cloudflare.cloudflared.plist

(to load it again)

3 Likes

Thanks a lot @nuno.diegues ! This indeed works now.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.