docs: simplify and update Cloudflare proxy setup instructions and documentation
Browse files
README.md
CHANGED
|
@@ -11,8 +11,7 @@ secrets:
|
|
| 11 |
- name: HF_TOKEN
|
| 12 |
description: HuggingFace token with write access. Used for automatic workspace backup.
|
| 13 |
- name: CLOUDFLARE_WORKERS_TOKEN
|
| 14 |
-
description:
|
| 15 |
-
|
| 16 |
---
|
| 17 |
|
| 18 |
<!-- Badges -->
|
|
@@ -58,10 +57,8 @@ secrets:
|
|
| 58 |
|
| 59 |
Navigate to your new Space's **Settings**, scroll down to **Variables and secrets**, and add:
|
| 60 |
|
| 61 |
-
- `HF_TOKEN` β Your HuggingFace token with **Write** access (
|
| 62 |
-
- `CLOUDFLARE_WORKERS_TOKEN` β *(
|
| 63 |
-
- `CLOUDFLARE_PROXY_URL` β *(Optional)* Your Cloudflare Worker URL for outbound proxying if you already have a Worker. Check [Setup Guide](#-cloudflare-proxy-setup).
|
| 64 |
-
- `CLOUDFLARE_PROXY_SECRET` β *(Optional, Security Recommended)* Shared secret used between Space and Worker to prevent proxy abuse.
|
| 65 |
|
| 66 |
### Step 3: Deploy & Initialize
|
| 67 |
|
|
@@ -81,56 +78,32 @@ Use the built-in dashboard at the root URL (`/`) to track:
|
|
| 81 |
|
| 82 |
## π Cloudflare Proxy Setup
|
| 83 |
|
| 84 |
-
Hugging Face Free Tier
|
| 85 |
|
| 86 |
-
Automatic
|
| 87 |
|
| 88 |
-
|
| 89 |
-
2. Add `CLOUDFLARE_WORKERS_TOKEN` as a Space secret.
|
| 90 |
-
3. Restart the Space.
|
| 91 |
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
-
|
| 95 |
-
- generate a private shared secret automatically
|
| 96 |
-
- export `CLOUDFLARE_PROXY_URL` and `CLOUDFLARE_PROXY_SECRET` before n8n starts
|
| 97 |
-
- transparently proxy outbound external requests through Cloudflare by default
|
| 98 |
|
| 99 |
-
|
|
|
|
|
|
|
| 100 |
|
| 101 |
-
|
| 102 |
-
- Token type: `API Token`
|
| 103 |
-
- Account permission: `Workers Scripts: Edit`
|
| 104 |
-
- Account auto-discovery is built in; `CLOUDFLARE_ACCOUNT_ID` is not required
|
| 105 |
|
| 106 |
-
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
3. choose worker name (e.g. h8n-proxy) and deploy.
|
| 113 |
-
4. Click on "Edit Code" button, paste the code from [cloudflare-worker.js](./cloudflare-worker.js).
|
| 114 |
-
5. Click on "Deploy" button.
|
| 115 |
-
6. Copy the Worker URL (e.g., `https://h8n-proxy.yourname.workers.dev`).
|
| 116 |
-
7. Add this URL as the `CLOUDFLARE_PROXY_URL` secret in your Hugging8n Space settings.
|
| 117 |
-
8. (Optional, Recommended) In Cloudflare Worker settings, add a secret binding named `CLOUDFLARE_PROXY_SECRET`.
|
| 118 |
-
9. (Optional, Recommended) Add the same value in your Space secrets as `CLOUDFLARE_PROXY_SECRET`.
|
| 119 |
-
|
| 120 |
-
If you skip steps 8-9, proxying still works. The secret simply adds request authentication between your app and worker.
|
| 121 |
-
|
| 122 |
-
Optional Worker vars for tighter control:
|
| 123 |
-
|
| 124 |
-
- `ALLOWED_TARGETS` (comma-separated; only used when `ALLOW_PROXY_ALL=false`)
|
| 125 |
-
- `ALLOW_PROXY_ALL` (`true` by default; proxies all external traffic except HF-internal hosts)
|
| 126 |
-
|
| 127 |
-
Default behavior:
|
| 128 |
-
|
| 129 |
-
- `CLOUDFLARE_PROXY_DOMAINS=*`
|
| 130 |
-
- all external traffic is proxied
|
| 131 |
-
- Hugging Face internal hosts stay direct automatically
|
| 132 |
-
|
| 133 |
-
That wider default is intentional so Google nodes, Telegram, WhatsApp-related APIs, Discord, and other external integrations work without extra domain tuning.
|
| 134 |
|
| 135 |
## πΎ Persistent Backup
|
| 136 |
|
|
@@ -146,7 +119,7 @@ Hugging8n automatically creates a private dataset named `hugging8n-backup` in yo
|
|
| 146 |
|
| 147 |
## π Staying Alive *(Recommended on Free HF Spaces)*
|
| 148 |
|
| 149 |
-
To help keep your Space awake, set up an external UptimeRobot monitor directly from the dashboard UI.
|
| 150 |
|
| 151 |
1. Open your Space's dashboard (`/`).
|
| 152 |
2. Find the **Keep Space Awake** section.
|
|
@@ -165,12 +138,13 @@ Customize your instance with these environment variables:
|
|
| 165 |
| `N8N_LOG_LEVEL` | `error` | Set to `info` or `debug` for more details |
|
| 166 |
| `CLOUDFLARE_WORKERS_TOKEN` | β | Cloudflare API token for automatic Worker setup |
|
| 167 |
| `CLOUDFLARE_PROXY_DOMAINS` | `*` | Comma-separated domains to proxy (or `*` for all external traffic) |
|
| 168 |
-
| `CLOUDFLARE_PROXY_SECRET` | β | Optional shared secret for
|
| 169 |
-
| `
|
|
|
|
| 170 |
| `SPACE_HOST_OVERRIDE` | β | Override detected host for custom domains |
|
| 171 |
-
| `N8N_STARTUP_TIMEOUT` | `180` | Max seconds to wait for n8n readiness
|
| 172 |
| `UPTIMEROBOT_SETUP_ENABLED` | `true` | Enable/disable dashboard helper endpoint |
|
| 173 |
-
| `UPTIMEROBOT_RATE_LIMIT_PER_MINUTE` | `5` |
|
| 174 |
|
| 175 |
## π» Local Development
|
| 176 |
|
|
|
|
| 11 |
- name: HF_TOKEN
|
| 12 |
description: HuggingFace token with write access. Used for automatic workspace backup.
|
| 13 |
- name: CLOUDFLARE_WORKERS_TOKEN
|
| 14 |
+
description: Cloudflare API token for automatic Worker proxy setup.
|
|
|
|
| 15 |
---
|
| 16 |
|
| 17 |
<!-- Badges -->
|
|
|
|
| 57 |
|
| 58 |
Navigate to your new Space's **Settings**, scroll down to **Variables and secrets**, and add:
|
| 59 |
|
| 60 |
+
- `HF_TOKEN` β Your HuggingFace token with **Write** access (for automatic backup).
|
| 61 |
+
- `CLOUDFLARE_WORKERS_TOKEN` β **(Highly Recommended)** Cloudflare API token. Hugging8n will automatically create and configure a Worker proxy for you.
|
|
|
|
|
|
|
| 62 |
|
| 63 |
### Step 3: Deploy & Initialize
|
| 64 |
|
|
|
|
| 78 |
|
| 79 |
## π Cloudflare Proxy Setup
|
| 80 |
|
| 81 |
+
Hugging Face Free Tier often restricts outbound connections to services like Telegram, Discord, and WhatsApp. Hugging8n solves this with a **Transparent Outbound Proxy** via Cloudflare Workers.
|
| 82 |
|
| 83 |
+
### β‘ Automatic Setup (Recommended)
|
| 84 |
|
| 85 |
+
This is the easiest way. Hugging8n will handle the deployment for you.
|
|
|
|
|
|
|
| 86 |
|
| 87 |
+
1. Create a **Cloudflare API Token**:
|
| 88 |
+
- Go to [API Tokens](https://dash.cloudflare.com/profile/api-tokens).
|
| 89 |
+
- Create Token -> **Edit Cloudflare Workers** template.
|
| 90 |
+
- Ensure it has `Account: Workers Scripts: Edit` permissions.
|
| 91 |
+
2. Add the token as a secret named `CLOUDFLARE_WORKERS_TOKEN` in your Space Settings.
|
| 92 |
|
| 93 |
+
**What happens next?**
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
+
- Hugging8n automatically creates a Worker named after your Space.
|
| 96 |
+
- It generates a secure, private `CLOUDFLARE_PROXY_SECRET`.
|
| 97 |
+
- All restricted outbound traffic is automatically routed through this Worker.
|
| 98 |
|
| 99 |
+
### π οΈ Manual Setup
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
+
If you prefer to manage the Worker yourself:
|
| 102 |
|
| 103 |
+
1. Create a new Cloudflare Worker.
|
| 104 |
+
2. Paste the code from [cloudflare-worker.js](./cloudflare-worker.js) and deploy.
|
| 105 |
+
3. Add the Worker URL to your Space as `CLOUDFLARE_PROXY_URL`.
|
| 106 |
+
4. (Optional) Set a `CLOUDFLARE_PROXY_SECRET` in both the Worker (as a variable) and the Space (as a secret).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
## πΎ Persistent Backup
|
| 109 |
|
|
|
|
| 119 |
|
| 120 |
## π Staying Alive *(Recommended on Free HF Spaces)*
|
| 121 |
|
| 122 |
+
To help keep your Space awake, set up an external [UptimeRobot](https://uptimerobot.com/) monitor directly from the dashboard UI.
|
| 123 |
|
| 124 |
1. Open your Space's dashboard (`/`).
|
| 125 |
2. Find the **Keep Space Awake** section.
|
|
|
|
| 138 |
| `N8N_LOG_LEVEL` | `error` | Set to `info` or `debug` for more details |
|
| 139 |
| `CLOUDFLARE_WORKERS_TOKEN` | β | Cloudflare API token for automatic Worker setup |
|
| 140 |
| `CLOUDFLARE_PROXY_DOMAINS` | `*` | Comma-separated domains to proxy (or `*` for all external traffic) |
|
| 141 |
+
| `CLOUDFLARE_PROXY_SECRET` | β | Optional shared secret for proxy authentication |
|
| 142 |
+
| `CLOUDFLARE_WORKER_NAME` | auto | Custom name for the automatically created Worker |
|
| 143 |
+
| `CLOUDFLARE_ACCOUNT_ID` | auto | Optional Cloudflare account ID override |
|
| 144 |
| `SPACE_HOST_OVERRIDE` | β | Override detected host for custom domains |
|
| 145 |
+
| `N8N_STARTUP_TIMEOUT` | `180` | Max seconds to wait for n8n readiness |
|
| 146 |
| `UPTIMEROBOT_SETUP_ENABLED` | `true` | Enable/disable dashboard helper endpoint |
|
| 147 |
+
| `UPTIMEROBOT_RATE_LIMIT_PER_MINUTE` | `5` | Rate limit for monitor creation |
|
| 148 |
|
| 149 |
## π» Local Development
|
| 150 |
|