Spaces:
Paused
Paused
refactor: update proxy logic and n8n configuration to host application at root instead of /app/ prefix
Browse filesFiles changed (3)
- README.md+32-15
- health-server.js+14-3
- start.sh+2-2
20 unmodified lines2122232425262728291 unmodified line313233343536373839404142434445464748495051525354555657585920 unmodified lines- β‘ **Zero Config:** Duplicate this Space, set `HF_TOKEN`, and you're ready.- πΎ **Persistent Backup:** Workflows and credentials back up automatically to a private HF Dataset.- π **Secure by Default:** Uses n8n v2's built-in user management. No more insecure environment variables.- π³ **Docker Native:** Optimized for the free HF Spaces tier.- π **Dashboard UI:** Beautiful management interface at the root URL.- β° **Built-in Keep-Alive:** Easily setup UptimeRobot from the dashboard.## π Quick Start1 unmodified line[](https://huggingface.co/spaces/somratpro/Hugging8n?duplicate=true)### Step 2: Add Your HF_TOKENAdd your HuggingFace token with **write** access to the Space Secrets. This enables automatic backup so your workflows aren't lost on restart.### Step 3: Set Up AuthWhen the Space starts, visit the URL and click **Open n8n Editor**. On the first run, n8n will ask you to create an owner account. **This is your primary login.**## π AuthenticationHugging8n uses n8n's native user management.1. The first person to visit `/app/` on a fresh install becomes the owner.2. If you are restoring from a backup, your existing user accounts will be active.## πΎ Persistent BackupYour data is synced to a private dataset named `hugging8n-backup` in your HF account.## ποΈ Architecture- `/` : Premium Dashboard (Status, Uptime, Keep-Alive setup)- `/app/` : n8n Workflow Editor- `/health` : Health check endpoint*Made with β€οΈ by [@somratpro](https://github.com/somratpro)*20 unmodified lines2122232425262728291 unmodified line3132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757620 unmodified lines- β‘ **Zero Config:** Duplicate this Space, set `HF_TOKEN`, and you're ready.- πΎ **Persistent Backup:** Workflows and credentials back up automatically to a private HF Dataset.- π **Secure by Default:** Uses n8n v2's built-in user management. No more insecure environment variables.- π **Premium Dashboard:** Live status monitoring, uptime tracking, and integrated keep-alive tools.- β° **Built-in Keep-Alive:** Easily setup UptimeRobot directly from the dashboard UI.- π³ **Optimized Infrastructure:** Clean startup logs, minimal resource usage, and production-ready proxy.## π Quick Start1 unmodified line[](https://huggingface.co/spaces/somratpro/Hugging8n?duplicate=true)### Step 2: Configure SecretsGo to **Settings > Secrets** and add:- `HF_TOKEN`: Your HuggingFace token with **Write** access.### Step 3: Initialize n8n1. Wait for the Space to build.2. Visit the Space URL and click **Open n8n Editor**.3. Create your owner account (this is your primary login).## βοΈ ConfigurationYou can customize Hugging8n using Environment Variables (Settings > Variables):| Variable | Default | Description || :--- | :--- | :--- || `SYNC_INTERVAL` | `180` | Backup frequency in seconds. || `GENERIC_TIMEZONE` | `UTC` | Timezone for n8n. || `N8N_LOG_LEVEL` | `error` | Set to `info` for more verbose logs. || `SPACE_HOST_OVERRIDE` | - | Override the detected host if using a custom domain. |## π Authentication & SecurityHugging8n uses n8n's native user management.- The first person to visit `/app/` on a fresh install becomes the **Owner**.- **Important:** If you delete the Space and haven't set up `HF_TOKEN`, your users and workflows will be lost.- **Permissions:** The startup script uses `umask 0077` to ensure all sensitive data is restricted to the node user.## πΎ Persistent BackupHugging8n automatically creates and maintains a private dataset in your Hugging Face account named `hugging8n-backup`.- **Sync Status:** You can check the current sync health directly on the Hugging8n Dashboard.- **Restoration:** On every startup, Hugging8n pulls the latest state from your dataset before launching n8n.## ποΈ Architecture- `/` : **Premium Dashboard** (Management & Monitoring)- `/app/` : **n8n Workflow Editor**- `/health` : **Health Check** (Used by the internal proxy and external monitors)---*Made with β€οΈ by [@somratpro](https://github.com/somratpro)*
298 unmodified lines29930030130230330430530630 unmodified lines337338339340341342343298 unmodified lines);}// Proxy to n8n (pass full path as n8n is configured with N8N_PATH=/app/)const proxyPath = pathname;const proxyHeaders = {...req.headers,host: `127.0.0.1:${TARGET_PORT}`,30 unmodified linesserver.on("upgrade", (req, socket, head) => {const url = parseRequestUrl(req.url);const proxyPath = url.pathname;const proxySocket = net.connect(TARGET_PORT, TARGET_HOST, () => {proxySocket.write(`${req.method} ${proxyPath}${url.search} HTTP/${req.httpVersion}\r\n`,298 unmodified lines29930030130230330430530630730830931031131230 unmodified lines343344345346347348349350351352353354298 unmodified lines);}// Proxy to n8n// We strip the /app prefix if present, as n8n will be configured with N8N_PATH=/let proxyPath = pathname;if (proxyPath.startsWith(APP_BASE)) {proxyPath = proxyPath.substring(APP_BASE.length);}if (!proxyPath.startsWith("/")) proxyPath = "/" + proxyPath;const proxyHeaders = {...req.headers,host: `127.0.0.1:${TARGET_PORT}`,30 unmodified linesserver.on("upgrade", (req, socket, head) => {const url = parseRequestUrl(req.url);let proxyPath = url.pathname;if (proxyPath.startsWith(APP_BASE)) {proxyPath = proxyPath.substring(APP_BASE.length);}if (!proxyPath.startsWith("/")) proxyPath = "/" + proxyPath;const proxySocket = net.connect(TARGET_PORT, TARGET_HOST, () => {proxySocket.write(`${req.method} ${proxyPath}${url.search} HTTP/${req.httpVersion}\r\n`,
14 unmodified lines151617181920212214 unmodified linesSPACE_HOST_DETECTED="${SPACE_HOST_OVERRIDE:-${SPACE_HOST:-}}"if [ -n "$SPACE_HOST_DETECTED" ]; thenexport N8N_HOST="${N8N_HOST:-$SPACE_HOST_DETECTED}"# Updated for /app base pathexport N8N_PATH="/app/"export WEBHOOK_URL="${WEBHOOK_URL:-https://${SPACE_HOST_DETECTED}/app/}"export N8N_EDITOR_BASE_URL="${N8N_EDITOR_BASE_URL:-https://${SPACE_HOST_DETECTED}/app/}"fi14 unmodified lines151617181920212214 unmodified linesSPACE_HOST_DETECTED="${SPACE_HOST_OVERRIDE:-${SPACE_HOST:-}}"if [ -n "$SPACE_HOST_DETECTED" ]; thenexport N8N_HOST="${N8N_HOST:-$SPACE_HOST_DETECTED}"# n8n runs at / internally; proxy handles /app prefix strippingexport N8N_PATH="/"export WEBHOOK_URL="${WEBHOOK_URL:-https://${SPACE_HOST_DETECTED}/app/}"export N8N_EDITOR_BASE_URL="${N8N_EDITOR_BASE_URL:-https://${SPACE_HOST_DETECTED}/app/}"fi
README.md+32-15
health-server.js+14-3
start.sh+2-2