Created
February 25, 2025 02:48
-
-
Save raybird/bbc448e0151dc4720a51cb2d1abd74de to your computer and use it in GitHub Desktop.
cloudflare/cloudflared
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if a port number is provided | |
if [ -z "$1" ]; then | |
echo "Please provide a port number. Usage: ./tunnel.sh <port>" | |
exit 1 | |
fi | |
# Get the port number | |
PORT=$1 | |
# Detect the operating system type | |
OS_TYPE=$(uname) | |
# Execute different commands based on the operating system | |
if [[ "$OS_TYPE" == "Linux" ]]; then | |
echo "Running Cloudflare Tunnel on native Linux system..." | |
docker run --network host cloudflare/cloudflared:2024.11.1 tunnel --url http://localhost:$PORT | |
elif [[ "$OS_TYPE" == "Darwin" || "$OS_TYPE" == "MINGW"* || "$OS_TYPE" == "CYGWIN"* ]]; then | |
echo "Running Cloudflare Tunnel on macOS or Windows system..." | |
docker run cloudflare/cloudflared:2024.11.1 tunnel --url http://host.docker.internal:$PORT | |
else | |
echo "Unsupported operating system: $OS_TYPE" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment