# Cloudflare Tunnel Setup Guide for Localhost Applications ## Prerequisites Install[ cloudflare tunnel ](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/)for your local machine. ## Step 1: Create a Cloudflare Tunnel 1. Open a terminal and run: ``` cloudflared tunnel create ``` Replace `` with a name for your tunnel. 2. Note the Tunnel ID from the output. You'll need this later. ## Step 2: Create the Configuration File 1. Create a new YAML file: ``` nano ~/.cloudflared/config-.yml ``` Replace `` with your application name (e.g., plex, nextcloud). 2. Add the following content to the file: ```yaml tunnel: credentials-file: /home//.cloudflared/.json ingress: - hostname: ..com service: http://localhost: - service: http_status:404 ``` Replace the placeholders: - ``: The Tunnel ID from step 1 - ``: Your system username - ``: The subdomain for your app (e.g., plex, nextcloud) - ``: Your actual domain name - ``: The local port your application uses (e.g., 32400 for Plex) 3. Save and exit the editor (Ctrl+X, then Y, then Enter in nano). ## Step 3: Configure DNS 1. Log in to your Cloudflare dashboard. 2. Go to the DNS settings for your domain. 3. Add a CNAME record: - Type: CNAME - Name: `` (e.g., plex, nextcloud) - Target: `.cfargotunnel.com` - Proxy status: Proxied (orange cloud icon) ## Step 4: Start the Tunnel 1. Run the tunnel: ``` cloudflared tunnel --config ~/.cloudflared/config-.yml run ``` ## Step 5: Configure Your Application (if necessary) For some applications, you may need to update their settings: 1. Open your application's settings. 2. Look for options like "Custom URLs", "Remote Access", or "Trusted Proxies". 3. Add your Cloudflare Tunnel URL: `https://..com` ## Step 6: Access Your Application 1. Open a web browser. 2. Go to `https://..com` ## Troubleshooting If you encounter issues: 1. Ensure your application is running and accessible at `http://localhost:` 2. Check the cloudflared logs for any error messages 3. Verify your Cloudflare DNS settings 4. Check your application's logs for any connection or proxy-related issues Remember to replace all placeholders with your actual values when following these steps.