Skip to content

Commit 55bf5d2

Browse files
committed
Updated README.md to add cloudflared info for macos
1 parent 2c274a9 commit 55bf5d2

1 file changed

Lines changed: 35 additions & 4 deletions

File tree

README.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ export CF_TUNNEL_NAME=fzryzen
9393
export CF_TARGET_DOMAIN=fzryzen.afzalex.com
9494
```
9595

96-
9796
Prerequisites
9897
- `afzalex.com` or any other domain is added to Cloudflare
9998
- Nameservers are pointing to Cloudflare
@@ -126,17 +125,19 @@ Create the Cloudflared config file
126125
export TUNNEL_ID=$(basename ~/.cloudflared/*.json .json)
127126
cat <<EOF | envsubst | tee /tmp/cloudflared-config.yml
128127
tunnel: ${TUNNEL_ID}
129-
credentials-file: /root/.cloudflared/${TUNNEL_ID}.json
128+
credentials-file: ${HOME}/.cloudflared/${TUNNEL_ID}.json
130129
131130
ingress:
132-
- hostname: $CF_TARGET_DOMAIN
131+
- hostname: ${CF_TARGET_DOMAIN}
133132
service: http://localhost:80
134133
135134
- service: http_status:404
136135
EOF
137136
```
138137

139-
Copy this config into /etc/cloudflared directory and then install cloudflared service
138+
**Install service and enable it**
139+
140+
For unix based systems :
140141
```bash
141142
sudo mkdir -p /etc/cloudflared
142143
sudo cp /tmp/cloudflared-config.yml /etc/cloudflared/config.yml
@@ -145,6 +146,36 @@ sudo systemctl enable cloudflared
145146
sudo systemctl start cloudflared
146147
```
147148

149+
For macOS :
150+
```bash
151+
cp /tmp/cloudflared-config.yml ~/cloudflared/config.yml
152+
sudo cloudflared service install
153+
```
154+
155+
Critical fix in macOS to run cloudflared tunnel as service
156+
```bash
157+
PLIST="$HOME/Library/LaunchAgents/com.cloudflare.cloudflared.plist"
158+
159+
/usr/libexec/PlistBuddy -c "Delete :ProgramArguments" "$PLIST"
160+
/usr/libexec/PlistBuddy -c "Add :ProgramArguments array" "$PLIST"
161+
/usr/libexec/PlistBuddy -c "Add :ProgramArguments:0 string /opt/homebrew/bin/cloudflared" "$PLIST"
162+
/usr/libexec/PlistBuddy -c "Add :ProgramArguments:1 string tunnel" "$PLIST"
163+
/usr/libexec/PlistBuddy -c "Add :ProgramArguments:2 string run" "$PLIST"
164+
/usr/libexec/PlistBuddy -c "Add :ProgramArguments:3 string fzmacair" "$PLIST"
165+
166+
plutil -lint "$PLIST"
167+
168+
UID=$(id -u)
169+
launchctl bootout "gui/$UID" "$PLIST" 2>/dev/null
170+
launchctl bootstrap "gui/$UID" "$PLIST"
171+
launchctl kickstart -k "gui/$UID/com.cloudflare.cloudflared"
172+
```
173+
174+
175+
To check if it is routing from internet
176+
```bash
177+
cloudflared tunnel info fzmacair
178+
```
148179

149180

150181
### EC2 user-data to add web server with web page on 80 port number

0 commit comments

Comments
 (0)