docs: cleanup project and update documentation for universal proxy
Browse files- .env.example +6 -1
- DISCORD_PROXY_GUIDE.md +0 -48
- OUTBOUND_PROXY_GUIDE.md +41 -0
- README.md +6 -3
- TASK_SUMMARY.md +0 -55
.env.example
CHANGED
|
@@ -36,8 +36,13 @@ N8N_PYTHON_NODES_ENABLED=false
|
|
| 36 |
N8N_TASK_RUNNERS_ENABLED=false
|
| 37 |
N8N_LICENSE_AUTO_RENEW_ENABLED=false
|
| 38 |
N8N_LOG_LEVEL=error
|
| 39 |
-
|
| 40 |
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
# BUILD-TIME VARIABLE (HF Spaces: add as Variable, not Secret)
|
| 42 |
# -----------------------------------------------------------------------------
|
| 43 |
|
|
|
|
| 36 |
N8N_TASK_RUNNERS_ENABLED=false
|
| 37 |
N8N_LICENSE_AUTO_RENEW_ENABLED=false
|
| 38 |
N8N_LOG_LEVEL=error
|
|
|
|
| 39 |
# -----------------------------------------------------------------------------
|
| 40 |
+
# NETWORK β Outbound Proxy (Bypass HF Blocks)
|
| 41 |
+
# -----------------------------------------------------------------------------
|
| 42 |
+
# Your Cloudflare Worker URL (e.g. h8n-proxy.somrat.workers.dev)
|
| 43 |
+
OUTBOUND_PROXY_URL=
|
| 44 |
+
# Comma-separated list of domains to proxy. Use "*" to proxy everything.
|
| 45 |
+
OUTBOUND_PROXY_DOMAINS=api.telegram.org,discord.com,discordapp.com
|
| 46 |
# BUILD-TIME VARIABLE (HF Spaces: add as Variable, not Secret)
|
| 47 |
# -----------------------------------------------------------------------------
|
| 48 |
|
DISCORD_PROXY_GUIDE.md
DELETED
|
@@ -1,48 +0,0 @@
|
|
| 1 |
-
# π οΈ How to Create a Free Discord Proxy
|
| 2 |
-
|
| 3 |
-
Hugging Face officially blocks outgoing connections to Discord's IP addresses on Free Tier Spaces to prevent spam. While our built-in DNS script cleanly bypasses blocks for Telegram and WhatsApp, Discord is blocked at the physical IP firewall level.
|
| 4 |
-
|
| 5 |
-
This means the native n8n "Discord" node will always hang and fail with a "Connection closed unexpectedly" error.
|
| 6 |
-
|
| 7 |
-
To work around this, you can easily create your own private Discord proxy using Cloudflare Workers. It takes about 2 minutes and is 100% free (allowing up to 100,000 requests per day).
|
| 8 |
-
|
| 9 |
-
## Step-by-Step Guide
|
| 10 |
-
|
| 11 |
-
### Step 1: Create a Cloudflare Worker
|
| 12 |
-
|
| 13 |
-
1. Log into [Cloudflare](https://dash.cloudflare.com/) (create an account if you don't have one).
|
| 14 |
-
2. On the left sidebar, go to **Workers & Pages**.
|
| 15 |
-
3. Click **Create Worker** -> **Start with Hello World!**.
|
| 16 |
-
4. Name it something memorable, like `discord-proxy`, and click **Deploy**.
|
| 17 |
-
|
| 18 |
-
### Step 2: Add the Proxy Code
|
| 19 |
-
|
| 20 |
-
1. Once deployed, click the **Edit Code** button.
|
| 21 |
-
2. In the online code editor, delete the existing code and replace it entirely with this 6-line snippet:
|
| 22 |
-
|
| 23 |
-
```javascript
|
| 24 |
-
export default {
|
| 25 |
-
async fetch(request) {
|
| 26 |
-
const url = new URL(request.url);
|
| 27 |
-
url.hostname = 'discord.com';
|
| 28 |
-
return fetch(new Request(url, request));
|
| 29 |
-
}
|
| 30 |
-
}
|
| 31 |
-
```
|
| 32 |
-
|
| 33 |
-
1. Click **Save and Deploy** in the top right corner. Cloudflare will generate a unique URL for you (e.g., `https://discord-proxy.yourname.workers.dev`).
|
| 34 |
-
|
| 35 |
-
### Step 3: Use the Proxy in n8n
|
| 36 |
-
|
| 37 |
-
Because the native Discord Node hardcodes connections to `discord.com` when using Bot tokens, you must use the **Webhook** method.
|
| 38 |
-
|
| 39 |
-
1. Add the standard **Discord** node to your n8n workflow.
|
| 40 |
-
2. Under "Authentication", select **Webhook**.
|
| 41 |
-
3. Take your normal Discord Webhook URL and replace `discord.com` with your new worker domain.
|
| 42 |
-
* *Original:* `https://discord.com/api/webhooks/123456/abcdef`
|
| 43 |
-
* *New:* `https://discord-proxy.yourname.workers.dev/api/webhooks/123456/abcdef`
|
| 44 |
-
4. Create a new Discord Webhook Credential in n8n and paste that **New URL** into the "Webhook URL" field.
|
| 45 |
-
5. Setup your message (e.g., set the text to "Hello World") and click **Execute Node**. Your message will instantly appear in Discord!
|
| 46 |
-
|
| 47 |
-
---
|
| 48 |
-
*Note: If you ever upgrade your Hugging Face Space to a paid hardware tier, the outgoing firewall restriction is removed, and you can go back to using the native n8n Discord node directly!*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OUTBOUND_PROXY_GUIDE.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π Outbound 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 Outbound Proxy** that allows you to bypass these restrictions using a single Cloudflare Worker.
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## π Setup in 2 Minutes
|
| 10 |
+
|
| 11 |
+
### Step 1: Deploy your Cloudflare Worker
|
| 12 |
+
1. Log in to [dash.cloudflare.com](https://dash.cloudflare.com/).
|
| 13 |
+
2. Go to **Workers & Pages** -> **Create Worker**.
|
| 14 |
+
3. Name it (e.g., `h8n-proxy`).
|
| 15 |
+
4. Paste the code from [outbound-proxy-worker.js](./outbound-proxy-worker.js) into the editor.
|
| 16 |
+
5. Click **Deploy**.
|
| 17 |
+
6. Copy your Worker URL (e.g., `h8n-proxy.yourname.workers.dev`).
|
| 18 |
+
|
| 19 |
+
### Step 2: Configure Hugging8n
|
| 20 |
+
Go to your Space **Settings** -> **Variables** and add:
|
| 21 |
+
|
| 22 |
+
1. **`OUTBOUND_PROXY_URL`**:
|
| 23 |
+
- Value: `h8n-proxy.yourname.workers.dev` (You can omit the `https://`).
|
| 24 |
+
|
| 25 |
+
2. **`OUTBOUND_PROXY_DOMAINS`** (Optional):
|
| 26 |
+
- **Default**: Proxies Telegram and Discord only.
|
| 27 |
+
- **Wildcard Mode**: Set this to `*` to proxy **every single request** n8n makes to the outside world. This is the most reliable way to ensure no node ever gets blocked.
|
| 28 |
+
|
| 29 |
+
### Step 3: Restart Space
|
| 30 |
+
Hugging8n will now automatically intercept all requests to the blocked domains and route them through your worker. **You do not need to change any URLs inside your n8n workflows.**
|
| 31 |
+
|
| 32 |
+
---
|
| 33 |
+
|
| 34 |
+
## π οΈ How it Works
|
| 35 |
+
|
| 36 |
+
1. **DNS Fix**: Hugging8n uses a built-in DNS-over-HTTPS (DoH) resolver to get the real IPs of blocked domains, bypassing HF's sinkholed DNS.
|
| 37 |
+
2. **SNI Bypass**: The transparent proxy changes the "label" (SNI) of your traffic to match your Cloudflare domain. Hugging Face sees you connecting to Cloudflare (allowed) instead of Telegram/Discord (blocked).
|
| 38 |
+
3. **Universal Routing**: Using the `x-target-host` header, one single worker can handle multiple different services dynamically.
|
| 39 |
+
|
| 40 |
+
---
|
| 41 |
+
*If you upgrade to a paid Space, these firewalls are removed and you no longer need this proxy.*
|
README.md
CHANGED
|
@@ -22,6 +22,7 @@ secrets:
|
|
| 22 |
- πΎ **Persistent Backup:** Workflows and credentials back up automatically to a private HF Dataset.
|
| 23 |
- π **Secure by Default:** Uses n8n v2's built-in user management. No more insecure environment variables.
|
| 24 |
- π **Premium Dashboard:** Live status monitoring, uptime tracking, and integrated keep-alive tools.
|
|
|
|
| 25 |
- β° **Built-in Keep-Alive:** Easily setup UptimeRobot directly from the dashboard UI.
|
| 26 |
- π³ **Optimized Infrastructure:** Clean startup logs, minimal resource usage, and production-ready proxy.
|
| 27 |
|
|
@@ -51,6 +52,8 @@ You can customize Hugging8n using Environment Variables (Settings > Variables):
|
|
| 51 |
| `SYNC_INTERVAL` | `180` | Backup frequency in seconds. |
|
| 52 |
| `GENERIC_TIMEZONE` | `UTC` | Timezone for n8n. |
|
| 53 |
| `N8N_LOG_LEVEL` | `error` | Set to `info` for more verbose logs. |
|
|
|
|
|
|
|
| 54 |
| `SPACE_HOST_OVERRIDE` | - | Override the detected host if using a custom domain. |
|
| 55 |
|
| 56 |
## π Authentication & Security
|
|
@@ -68,10 +71,10 @@ Hugging8n automatically creates and maintains a private dataset in your Hugging
|
|
| 68 |
|
| 69 |
## β οΈ Known Limitations & Workarounds
|
| 70 |
|
| 71 |
-
**
|
| 72 |
-
Hugging Face officially blocks outgoing connections to
|
| 73 |
|
| 74 |
-
π **[Read the
|
| 75 |
*(Upgrading to a paid Space removes this firewall restriction entirely).*
|
| 76 |
|
| 77 |
## ποΈ Architecture
|
|
|
|
| 22 |
- πΎ **Persistent Backup:** Workflows and credentials back up automatically to a private HF Dataset.
|
| 23 |
- π **Secure by Default:** Uses n8n v2's built-in user management. No more insecure environment variables.
|
| 24 |
- π **Premium Dashboard:** Live status monitoring, uptime tracking, and integrated keep-alive tools.
|
| 25 |
+
- π οΈ **Built-in Connectivity Fixes:** Automatic DNS-over-HTTPS (DoH) and Transparent Outbound Proxying to bypass platform networking blocks.
|
| 26 |
- β° **Built-in Keep-Alive:** Easily setup UptimeRobot directly from the dashboard UI.
|
| 27 |
- π³ **Optimized Infrastructure:** Clean startup logs, minimal resource usage, and production-ready proxy.
|
| 28 |
|
|
|
|
| 52 |
| `SYNC_INTERVAL` | `180` | Backup frequency in seconds. |
|
| 53 |
| `GENERIC_TIMEZONE` | `UTC` | Timezone for n8n. |
|
| 54 |
| `N8N_LOG_LEVEL` | `error` | Set to `info` for more verbose logs. |
|
| 55 |
+
| `OUTBOUND_PROXY_URL` | - | Your Cloudflare Worker URL (to bypass Discord/Telegram blocks). |
|
| 56 |
+
| `OUTBOUND_PROXY_DOMAINS` | (default) | Comma-separated list of domains to proxy. Use `*` to proxy everything. |
|
| 57 |
| `SPACE_HOST_OVERRIDE` | - | Override the detected host if using a custom domain. |
|
| 58 |
|
| 59 |
## π Authentication & Security
|
|
|
|
| 71 |
|
| 72 |
## β οΈ Known Limitations & Workarounds
|
| 73 |
|
| 74 |
+
**External Connectivity (Telegram/Discord/WhatsApp)**
|
| 75 |
+
Hugging Face officially blocks outgoing connections to specific services on Free Tier Spaces. Hugging8n includes a transparent proxy system to bypass this automatically.
|
| 76 |
|
| 77 |
+
π **[Read the Outbound Proxy Guide](./OUTBOUND_PROXY_GUIDE.md)**
|
| 78 |
*(Upgrading to a paid Space removes this firewall restriction entirely).*
|
| 79 |
|
| 80 |
## ποΈ Architecture
|
TASK_SUMMARY.md
DELETED
|
@@ -1,55 +0,0 @@
|
|
| 1 |
-
# Task Summary: Fixing Outbound Connectivity on Hugging Face Spaces
|
| 2 |
-
|
| 3 |
-
## Objective
|
| 4 |
-
Enable `n8n` (running on Hugging Face Spaces) to connect to blocked external services like Telegram API and Discord, bypassing the platform's network restrictions.
|
| 5 |
-
|
| 6 |
-
## Paths Explored
|
| 7 |
-
|
| 8 |
-
### 1. DNS Resolution Fix (DoH)
|
| 9 |
-
- **Problem**: HF Spaces intercept standard UDP/TCP DNS queries and return sinkholed IPs or `ENOTFOUND` for specific domains (Telegram, WhatsApp, Discord).
|
| 10 |
-
- **Solution**: Implemented a `dns-fix.js` preload script using `NODE_OPTIONS="--require /opt/dns-fix.js"`.
|
| 11 |
-
- **Method**: Monkey-patched `dns.lookup` to fall back to **DNS-over-HTTPS (DoH)** via Cloudflare (`1.1.1.1`) when system DNS fails.
|
| 12 |
-
- **Result**: Successfully resolved the correct IP addresses for `api.telegram.org`.
|
| 13 |
-
|
| 14 |
-
### 2. Forced DoH & IPv4 Priority
|
| 15 |
-
- **Observation**: Even when DNS worked, connections often failed with `ECONNRESET` or `SSL alert 0`.
|
| 16 |
-
- **Exploration**: Forced DoH for known blocked domains even if system DNS seemed to work (to bypass sinkholed IPs) and set `--dns-result-order=ipv4first`.
|
| 17 |
-
- **Result**: DNS was correct, but TCP/TLS handshakes were still being dropped by the HF firewall.
|
| 18 |
-
|
| 19 |
-
### 3. Transparent Application-Level Proxy
|
| 20 |
-
- **Idea**: Use Node.js 22's native `fetch()` (based on `undici`) which handles HF's networking better (Happy Eyeballs).
|
| 21 |
-
- **Method**: Monkey-patched `http.request` and `https.request` to route blocked domains through `fetch()`.
|
| 22 |
-
- **Result**: Encountered `Maximum call stack size exceeded` due to recursion between the patch and n8n's `axios`/`follow-redirects` library.
|
| 23 |
-
|
| 24 |
-
### 4. Comparison with HuggingClaw
|
| 25 |
-
- **Context**: The user pointed to `HuggingClaw` as a working example.
|
| 26 |
-
- **Analysis**: HuggingClaw uses an identical `dns-fix.js` and `Dockerfile` configuration.
|
| 27 |
-
- **Finding**: HuggingClaw's networking works because it likely connects to services that aren't strictly blocked or uses a different internal routing that `n8n` (a larger app) might be disrupting.
|
| 28 |
-
|
| 29 |
-
### 5. Transparent Application-Level Proxy (Implemented)
|
| 30 |
-
- **Status**: β
**Partially Fixed** (Requires External Worker)
|
| 31 |
-
- **Method**: Implemented `outbound-fix.js` which patches `https.request` to redirect blocked traffic through a single **Universal Cloudflare Worker**.
|
| 32 |
-
- **Multi-Service Support**: The patch adds a `x-target-host` header to the request. The Worker reads this header to determine the final destination (Telegram, Discord, etc.), allowing one Worker to handle all blocked services.
|
| 33 |
-
- **Why it works**: By changing the target hostname to your custom Cloudflare Worker, we change the SNI (Server Name Indication). Since Cloudflare is not blocked by HF, the connection succeeds.
|
| 34 |
-
- **Recursion Guard**: Uses a private property `_proxied: true` on the options object to ensure requests aren't intercepted twice.
|
| 35 |
-
|
| 36 |
-
## Final Conclusion & Recommendations
|
| 37 |
-
|
| 38 |
-
The connectivity issue on Hugging Face Spaces for `n8n` is now fully understood and has a working solution:
|
| 39 |
-
1. **DNS Layer**: **Fixed** via `dns-fix.js` (DoH).
|
| 40 |
-
2. **Network/SNI Layer**: **Addressed** via `outbound-fix.js` (Transparent Proxy).
|
| 41 |
-
|
| 42 |
-
### Next Steps for User
|
| 43 |
-
1. **Deploy Cloudflare Worker**: Use the code provided in `outbound-proxy-worker.js`.
|
| 44 |
-
2. **Set Environment Variable**: In HF Space Settings, set `OUTBOUND_PROXY_URL` to your worker's URL (e.g., `https://my-proxy.somrat.workers.dev`).
|
| 45 |
-
3. **Restart Space**: The `n8n` instance will now automatically route all Telegram and Discord requests through your proxy without needing to change any workflow nodes.
|
| 46 |
-
|
| 47 |
-
## Current State of Repository
|
| 48 |
-
- `dns-fix.js`: Robust DoH fallback with recursion guards.
|
| 49 |
-
- `outbound-fix.js`: Transparent SNI-bypass proxy with `x-target-host` support.
|
| 50 |
-
- `outbound-proxy-worker.js`: Universal Cloudflare Worker code for any blocked target.
|
| 51 |
-
- `Dockerfile`: Configured to preload both fixes.
|
| 52 |
-
- `access.md`: Contains test tokens and execution logs.
|
| 53 |
-
|
| 54 |
-
> [!IMPORTANT]
|
| 55 |
-
> The current setup fixes the **DNS issue**, but the **Firewall/SNI issue** remains. Future work should focus on implementing a lightweight outbound proxy or using a service like Cloudflare Tunnel if possible.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|