feat: rename proxy files and make CLOUDFLARE_PROXY_URL required
Browse files
OUTBOUND_PROXY_GUIDE.md β CLOUDFLARE_PROXY_GUIDE.md
RENAMED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
-
# π
|
| 2 |
|
| 3 |
Hugging Face Spaces officially blocks outgoing connections to specific services like **Telegram**, **WhatsApp**, and **Discord** on the free tier.
|
| 4 |
|
| 5 |
-
Hugging8n includes a built-in **Transparent
|
| 6 |
|
| 7 |
---
|
| 8 |
|
|
@@ -13,20 +13,20 @@ Hugging8n includes a built-in **Transparent Outbound Proxy** that allows you to
|
|
| 13 |
1. Log in to [dash.cloudflare.com](https://dash.cloudflare.com/).
|
| 14 |
2. Go to **Workers & Pages** -> **Create Worker**.
|
| 15 |
3. Name it (e.g., `h8n-proxy`).
|
| 16 |
-
4. Paste the code from [
|
| 17 |
5. Click **Deploy**.
|
| 18 |
6. Copy your Worker URL (e.g., `h8n-proxy.yourname.workers.dev`).
|
| 19 |
|
| 20 |
### Step 2: Configure Hugging8n
|
| 21 |
|
| 22 |
-
Go to your Space **Settings** -> **Variables** and add:
|
| 23 |
|
| 24 |
-
1. **`CLOUDFLARE_PROXY_URL`**:
|
| 25 |
- Value: `h8n-proxy.yourname.workers.dev` (You can omit the `https://`).
|
| 26 |
|
| 27 |
-
2. **`
|
| 28 |
- **Default**: Proxies Telegram and Discord only.
|
| 29 |
-
- **Wildcard Mode**: Set this to `*` to proxy **every single request** n8n makes to the outside world.
|
| 30 |
|
| 31 |
### Step 3: Restart Space
|
| 32 |
|
|
|
|
| 1 |
+
# π Cloudflare Proxy Guide
|
| 2 |
|
| 3 |
Hugging Face Spaces officially blocks outgoing connections to specific services like **Telegram**, **WhatsApp**, and **Discord** on the free tier.
|
| 4 |
|
| 5 |
+
Hugging8n includes a built-in **Transparent Cloudflare Proxy** that allows you to bypass these restrictions using a single Cloudflare Worker.
|
| 6 |
|
| 7 |
---
|
| 8 |
|
|
|
|
| 13 |
1. Log in to [dash.cloudflare.com](https://dash.cloudflare.com/).
|
| 14 |
2. Go to **Workers & Pages** -> **Create Worker**.
|
| 15 |
3. Name it (e.g., `h8n-proxy`).
|
| 16 |
+
4. Paste the code from [cloudflare-worker.js](./cloudflare-worker.js) into the editor.
|
| 17 |
5. Click **Deploy**.
|
| 18 |
6. Copy your Worker URL (e.g., `h8n-proxy.yourname.workers.dev`).
|
| 19 |
|
| 20 |
### Step 2: Configure Hugging8n
|
| 21 |
|
| 22 |
+
Go to your Space **Settings** -> **Variables** (or Secrets) and add:
|
| 23 |
|
| 24 |
+
1. **`CLOUDFLARE_PROXY_URL`** (Required):
|
| 25 |
- Value: `h8n-proxy.yourname.workers.dev` (You can omit the `https://`).
|
| 26 |
|
| 27 |
+
2. **`CLOUDFLARE_PROXY_DOMAINS`** (Optional):
|
| 28 |
- **Default**: Proxies Telegram and Discord only.
|
| 29 |
+
- **Wildcard Mode**: Set this to `*` to proxy **every single request** n8n makes to the outside world.
|
| 30 |
|
| 31 |
### Step 3: Restart Space
|
| 32 |
|
Dockerfile
CHANGED
|
@@ -30,10 +30,10 @@ WORKDIR /home/node/app
|
|
| 30 |
|
| 31 |
COPY --chown=node:node health-server.js /home/node/app/health-server.js
|
| 32 |
COPY --chown=node:node dns-fix.js /opt/dns-fix.js
|
| 33 |
-
COPY --chown=node:node
|
| 34 |
|
| 35 |
# Set NODE_OPTIONS after preload scripts are copied
|
| 36 |
-
ENV NODE_OPTIONS="--require /opt/dns-fix.js --require /opt/
|
| 37 |
COPY --chown=node:node n8n-sync.py /home/node/app/n8n-sync.py
|
| 38 |
COPY --chown=node:node setup-uptimerobot.sh /home/node/app/setup-uptimerobot.sh
|
| 39 |
COPY --chown=node:node start.sh /home/node/app/start.sh
|
|
|
|
| 30 |
|
| 31 |
COPY --chown=node:node health-server.js /home/node/app/health-server.js
|
| 32 |
COPY --chown=node:node dns-fix.js /opt/dns-fix.js
|
| 33 |
+
COPY --chown=node:node cloudflare-proxy.js /opt/cloudflare-proxy.js
|
| 34 |
|
| 35 |
# Set NODE_OPTIONS after preload scripts are copied
|
| 36 |
+
ENV NODE_OPTIONS="--require /opt/dns-fix.js --require /opt/cloudflare-proxy.js"
|
| 37 |
COPY --chown=node:node n8n-sync.py /home/node/app/n8n-sync.py
|
| 38 |
COPY --chown=node:node setup-uptimerobot.sh /home/node/app/setup-uptimerobot.sh
|
| 39 |
COPY --chown=node:node start.sh /home/node/app/start.sh
|
README.md
CHANGED
|
@@ -11,7 +11,7 @@ secrets:
|
|
| 11 |
- name: HF_TOKEN
|
| 12 |
description: HuggingFace token with write access (Settings > Tokens). Used for automatic backup.
|
| 13 |
- name: CLOUDFLARE_PROXY_URL
|
| 14 |
-
description: Your Cloudflare Worker URL to bypass platform blocks (Telegram/Discord).
|
| 15 |
---
|
| 16 |
|
| 17 |
# π Hugging8n
|
|
@@ -55,8 +55,8 @@ You can customize Hugging8n using Environment Variables (Settings > Variables):
|
|
| 55 |
| `SYNC_INTERVAL` | `180` | Backup frequency in seconds. |
|
| 56 |
| `GENERIC_TIMEZONE` | `UTC` | Timezone for n8n. |
|
| 57 |
| `N8N_LOG_LEVEL` | `error` | Set to `info` for more verbose logs. |
|
| 58 |
-
| `CLOUDFLARE_PROXY_URL` |
|
| 59 |
-
| `
|
| 60 |
| `SPACE_HOST_OVERRIDE` | - | Override the detected host if using a custom domain. |
|
| 61 |
|
| 62 |
## π Authentication & Security
|
|
@@ -79,7 +79,7 @@ Hugging8n automatically creates and maintains a private dataset in your Hugging
|
|
| 79 |
**External Connectivity (Telegram/Discord/WhatsApp)**
|
| 80 |
Hugging Face officially blocks outgoing connections to specific services on Free Tier Spaces. Hugging8n includes a transparent proxy system to bypass this automatically.
|
| 81 |
|
| 82 |
-
π **[Read the
|
| 83 |
*(Upgrading to a paid Space removes this firewall restriction entirely).*
|
| 84 |
|
| 85 |
## ποΈ Architecture
|
|
|
|
| 11 |
- name: HF_TOKEN
|
| 12 |
description: HuggingFace token with write access (Settings > Tokens). Used for automatic backup.
|
| 13 |
- name: CLOUDFLARE_PROXY_URL
|
| 14 |
+
description: Your Cloudflare Worker URL to bypass platform blocks (Telegram/Discord). Required for most external services.
|
| 15 |
---
|
| 16 |
|
| 17 |
# π Hugging8n
|
|
|
|
| 55 |
| `SYNC_INTERVAL` | `180` | Backup frequency in seconds. |
|
| 56 |
| `GENERIC_TIMEZONE` | `UTC` | Timezone for n8n. |
|
| 57 |
| `N8N_LOG_LEVEL` | `error` | Set to `info` for more verbose logs. |
|
| 58 |
+
| `CLOUDFLARE_PROXY_URL` | (Required) | Your Cloudflare Worker URL (to bypass Discord/Telegram blocks). |
|
| 59 |
+
| `CLOUDFLARE_PROXY_DOMAINS` | (default) | Comma-separated list of domains to proxy. Use `*` to proxy everything. |
|
| 60 |
| `SPACE_HOST_OVERRIDE` | - | Override the detected host if using a custom domain. |
|
| 61 |
|
| 62 |
## π Authentication & Security
|
|
|
|
| 79 |
**External Connectivity (Telegram/Discord/WhatsApp)**
|
| 80 |
Hugging Face officially blocks outgoing connections to specific services on Free Tier Spaces. Hugging8n includes a transparent proxy system to bypass this automatically.
|
| 81 |
|
| 82 |
+
π **[Read the Cloudflare Proxy Guide](./CLOUDFLARE_PROXY_GUIDE.md)**
|
| 83 |
*(Upgrading to a paid Space removes this firewall restriction entirely).*
|
| 84 |
|
| 85 |
## ποΈ Architecture
|
outbound-fix.js β cloudflare-proxy.js
RENAMED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
/**
|
| 2 |
-
*
|
| 3 |
*
|
| 4 |
* Patches https.request to redirect traffic for Telegram/Discord
|
| 5 |
* through a Cloudflare Worker proxy.
|
|
@@ -14,10 +14,10 @@ if (PROXY_URL && !PROXY_URL.startsWith("http://") && !PROXY_URL.startsWith("http
|
|
| 14 |
PROXY_URL = `https://${PROXY_URL}`;
|
| 15 |
}
|
| 16 |
|
| 17 |
-
const DEBUG = process.env.OUTBOUND_PROXY_DEBUG === "true";
|
| 18 |
|
| 19 |
// Allow user to define what to proxy. Use "*" to proxy everything except internal HF traffic.
|
| 20 |
-
const PROXY_DOMAINS = process.env.OUTBOUND_PROXY_DOMAINS || "api.telegram.org,discord.com,discordapp.com,gateway.discord.gg,status.discord.com";
|
| 21 |
const BLOCKED_DOMAINS = PROXY_DOMAINS.split(",").map(d => d.trim());
|
| 22 |
const PROXY_ALL = PROXY_DOMAINS === "*";
|
| 23 |
|
|
@@ -65,7 +65,7 @@ if (PROXY_URL) {
|
|
| 65 |
const alreadyProxied = options._proxied || (headers && headers["x-target-host"]);
|
| 66 |
|
| 67 |
if (shouldProxy && !alreadyProxied) {
|
| 68 |
-
if (DEBUG) console.log(`[
|
| 69 |
|
| 70 |
// 3. Create fresh options for the proxied request
|
| 71 |
const newOptions = (typeof options === "string" || options instanceof URL)
|
|
@@ -105,13 +105,13 @@ if (PROXY_URL) {
|
|
| 105 |
|
| 106 |
if (DEBUG) {
|
| 107 |
if (PROXY_ALL) {
|
| 108 |
-
console.log(`[
|
| 109 |
} else {
|
| 110 |
-
console.log(`[
|
| 111 |
}
|
| 112 |
-
console.log(`[
|
| 113 |
}
|
| 114 |
} catch (e) {
|
| 115 |
-
if (DEBUG) console.error(`[
|
| 116 |
}
|
| 117 |
}
|
|
|
|
| 1 |
/**
|
| 2 |
+
* Cloudflare Proxy: Transparent Fix for Blocked Domains
|
| 3 |
*
|
| 4 |
* Patches https.request to redirect traffic for Telegram/Discord
|
| 5 |
* through a Cloudflare Worker proxy.
|
|
|
|
| 14 |
PROXY_URL = `https://${PROXY_URL}`;
|
| 15 |
}
|
| 16 |
|
| 17 |
+
const DEBUG = process.env.CLOUDFLARE_PROXY_DEBUG === "true" || process.env.OUTBOUND_PROXY_DEBUG === "true";
|
| 18 |
|
| 19 |
// Allow user to define what to proxy. Use "*" to proxy everything except internal HF traffic.
|
| 20 |
+
const PROXY_DOMAINS = process.env.CLOUDFLARE_PROXY_DOMAINS || process.env.OUTBOUND_PROXY_DOMAINS || "api.telegram.org,discord.com,discordapp.com,gateway.discord.gg,status.discord.com";
|
| 21 |
const BLOCKED_DOMAINS = PROXY_DOMAINS.split(",").map(d => d.trim());
|
| 22 |
const PROXY_ALL = PROXY_DOMAINS === "*";
|
| 23 |
|
|
|
|
| 65 |
const alreadyProxied = options._proxied || (headers && headers["x-target-host"]);
|
| 66 |
|
| 67 |
if (shouldProxy && !alreadyProxied) {
|
| 68 |
+
if (DEBUG) console.log(`[cloudflare-proxy] Redirecting ${hostname}${path} -> ${proxy.hostname}`);
|
| 69 |
|
| 70 |
// 3. Create fresh options for the proxied request
|
| 71 |
const newOptions = (typeof options === "string" || options instanceof URL)
|
|
|
|
| 105 |
|
| 106 |
if (DEBUG) {
|
| 107 |
if (PROXY_ALL) {
|
| 108 |
+
console.log(`[cloudflare-proxy] Transparent proxy active in WILDCARD mode (Proxying ALL except HF internal)`);
|
| 109 |
} else {
|
| 110 |
+
console.log(`[cloudflare-proxy] Transparent proxy active for: ${BLOCKED_DOMAINS.join(", ")}`);
|
| 111 |
}
|
| 112 |
+
console.log(`[cloudflare-proxy] Target proxy: ${proxy.hostname}`);
|
| 113 |
}
|
| 114 |
} catch (e) {
|
| 115 |
+
if (DEBUG) console.error(`[cloudflare-proxy] Failed to initialize: ${e.message}`);
|
| 116 |
}
|
| 117 |
}
|
outbound-proxy-worker.js β cloudflare-worker.js
RENAMED
|
File without changes
|