惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

www.infosecurity-magazine.com
www.infosecurity-magazine.com
Vercel News
Vercel News
G
Google Developers Blog
MyScale Blog
MyScale Blog
The Register - Security
The Register - Security
I
InfoQ
Blog — PlanetScale
Blog — PlanetScale
D
DataBreaches.Net
Microsoft Security Blog
Microsoft Security Blog
V
Visual Studio Blog
V2EX - 技术
V2EX - 技术
F
Fortinet All Blogs
博客园_首页
S
Secure Thoughts
GbyAI
GbyAI
S
Security Affairs
N
News | PayPal Newsroom
Forbes - Security
Forbes - Security
Recent Announcements
Recent Announcements
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Security Archives - TechRepublic
Security Archives - TechRepublic
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
H
Heimdal Security Blog
A
About on SuperTechFans
P
Proofpoint News Feed
H
Help Net Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Y
Y Combinator Blog
L
LINUX DO - 最新话题
Apple Machine Learning Research
Apple Machine Learning Research
L
LangChain Blog
博客园 - 叶小钗
A
Arctic Wolf
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
人人都是产品经理
人人都是产品经理
T
Threat Research - Cisco Blogs
N
News and Events Feed by Topic
Security Latest
Security Latest
The Hacker News
The Hacker News
T
Tor Project blog
O
OpenAI News
博客园 - 三生石上(FineUI控件)
PCI Perspectives
PCI Perspectives
量子位
大猫的无限游戏
大猫的无限游戏
Stack Overflow Blog
Stack Overflow Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Build Your Own AI Automation with n8n: Self-Hosted, No-Code Agent
Mustafa ERBAY · 2026-06-16 · via DEV Community

Mustafa ERBAY

Automating workflows has always been a priority for me, especially for repetitive and error-prone manual processes. Recently, integrating AI capabilities into these automations offers a great opportunity for those, like me, who seek practical solutions. However, this integration often requires coding or complex API integrations. This is where "low-code/no-code" tools like n8n come into play. I used n8n to set up AI-powered agent flows on my own servers, without compromising data privacy and control. In this post, I will share my experience and explain how to do it step-by-step.

Why n8n and Self-Hosted AI Automation?

A few years ago, I experimented with different automation tools, especially for simple data transfers and notification flows. But when AI capabilities became involved, I either found them too expensive or avoided cloud-based solutions due to data security concerns. Especially in a client project where we needed to set up an automation handling sensitive financial data, a self-hosted solution became inevitable. n8n offers a wide range of integrations and, thanks to Docker support, I can easily host it on my own server.

For me, self-hosting is not just about cost advantage; it also means having complete control over my data. Especially when using AI agents, the question of how much of the data you send to LLMs is logged or used for training is always a concern. With an n8n setup under my control, I minimized these worries. Moreover, n8n's flexible structure gives me the freedom to add as many custom integrations or LLM providers as I want. This is a significant advantage for someone like me who enjoys testing different LLMs.

ℹ️ Data Privacy Priority

Especially when working with sensitive data, it's crucial to carefully review the data usage policies of cloud-based AI services. Self-hosted n8n offers more control in this regard, making it my preferred choice for critical workflows.

Setup Steps: Quick Start with Docker Compose

The easiest way to run n8n on your own server is by using Docker Compose. I usually write the docker-compose.yml file myself for simple setups. This gives me flexibility and makes debugging easier in case of potential issues. The example below will be sufficient for a basic n8n setup. Here, I'm using PostgreSQL as the database because n8n working with SQLite can lead to issues like WAL bloat, especially under high load or unexpected shutdowns. I also added Redis for caching and queueing, which improves performance.

First, create a directory on your server and place the docker-compose.yml file inside it:

mkdir n8n-ai-automation
cd n8n-ai-automation
nano docker-compose.yml

The docker-compose.yml content might look like this:

version: '3.8'

services:
  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - "5678:5678"
    environment:
      - N8N_HOST=${N8N_HOST:-localhost}
      - N8N_PORT=5678
      - N8N_PROTOCOL=${N8N_PROTOCOL:-http}
      - WEBHOOK_URL=${WEBHOOK_URL:-http://localhost:5678/}
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_DATABASE=${POSTGRES_DB:-n8n}
      - DB_POSTGRESDB_USER=${POSTGRES_USER:-n8n}
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD:-n8n}
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=${N8N_USER:-admin}
      - N8N_BASIC_AUTH_PASSWORD=${N8N_PASSWORD:-admin_password_change_me}
      - QUEUE_BULL_REDIS_HOST=redis
      - QUEUE_BULL_REDIS_PORT=6379
      - N8N_METRICS_ENABLED=true # For monitoring metrics with tools like Prometheus
    volumes:
      - n8n_data:/home/node/.n8n
    depends_on:
      - postgres
      - redis
    # Resource limits are important to protect against OOM killer
    deploy:
      resources:
        limits:
          memory: 2G
        reservations:
          memory: 1G

  postgres:
    image: postgres:15
    restart: always
    environment:
      - POSTGRES_DB=${POSTGRES_DB:-n8n}
      - POSTGRES_USER=${POSTGRES_USER:-n8n}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-n8n}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    deploy:
      resources:
        limits:
          memory: 512M
        reservations:
          memory: 256M

  redis:
    image: redis:7
    restart: always
    volumes:
      - redis_data:/data
    deploy:
      resources:
        limits:
          memory: 256M
        reservations:
          memory: 128M

volumes:
  n8n_data:
  postgres_data:
  redis_data:

This file defines the n8n, PostgreSQL, and Redis services. I configure n8n's database connection information and basic authentication settings using environment variables. Don't forget to use N8N_BASIC_AUTH_ACTIVE and the user/password variables for security. Additionally, I specified the amount of memory to be allocated to each service with limits and reservations under deploy.resources. This is critical, especially in VPS environments, to prevent excessive resource consumption and OOM-killed errors. Last month, I saw a build container for one of my side products get OOM-killed due to a sleep 360 command in its CI/CD pipeline, so defining resource limits from the start has become a habit.

After saving the file, you can start the services with the docker compose up -d command:

docker compose up -d

Within a few minutes, you can access the n8n interface at http://localhost:5678. If you are using a reverse proxy (like Nginx), you will need to adjust the N8N_HOST and N8N_PROTOCOL variables accordingly. I usually set up SSL termination with Nginx and publish n8n under an address like https://automations.mysite.com.

Creating Your First AI Agent Flow

n8n's power comes from its ability to create complex workflows through a visual interface without writing code. We can set up our first AI agent flow using a scenario where an incoming email is summarized and a notification is sent to Slack. This was a simple but effective method I used in a client project to quickly triage support emails.

  1. Trigger: To start the workflow, we can use an "Email" trigger. I usually set up a "Webhook" trigger and route emails from another service (e.g., Mailgun or a simple email parser I wrote) to this webhook. However, n8n also has its own "IMAP Email" or "Gmail" nodes. For simplicity, let's start with a "Manual Trigger" and then connect it to a real trigger later.

  2. LLM Node: Under the "AI" category, you will find many LLM (Large Language Model) nodes. I usually use "OpenAI" or "Generic LLM" nodes. The "Generic LLM" node provides access to different LLMs via OpenRouter or your own custom APIs. Drag and drop this node onto the canvas.

  3. Prompt Engineering: Inside the LLM node, we will enter a System Prompt and User Prompt to instruct it to summarize the email. Prompt engineering is critical here. While using AI for production planning in a manufacturing company's ERP, I repeatedly tested how detailed and guiding the prompts needed to be.

    System Prompt example:

    You are an AI assistant that summarizes incoming customer support emails.
    Focus on the main issue, the customer's name (if available), and any urgent requests.
    Keep the summary concise, maximum 3 sentences.
    

    User Prompt example:

    Summarize the following email:
    ---
    Subject: About the Defective Product
    From: Ayşe Yılmaz <ayse.yilmaz@example.com>
    Date: 2026-06-15
    Body: Hello, the X brand product I purchased with order number 12345 turned out to be defective. I have been using it for a week, and it suddenly stopped working yesterday. I urgently request a replacement. Please contact me as soon as possible. Thank you, Ayşe Yılmaz.
    ---
    

    You can dynamically link the content of the incoming email to this example using expressions like {{ $json.body.text }}.

  4. Slack Node: Add a "Slack" node to send the summary from the LLM to a Slack channel. When configuring the Slack node, you will need to provide a Webhook URL or Bot Token. You can link the output from the LLM node to the message part using {{ $node["LLM Node"].json["text"] }}.

After creating this flow, you can check if it works by clicking the "Test Workflow" button or by triggering a test email. As you can see, we have set up an AI-powered automation with a few drag-and-drop operations, without writing any code.

💡 Prompt Development Tips

Develop your prompts iteratively. You won't always get perfect results on the first try. Test for different scenarios and add specific instructions to guide the LLM's behavior. For example, "if the customer's name is not in the email, write 'Anonymous Customer'".

Real-World Agent Flows: RAG and Multi-LLM Integration

In more complex scenarios, our AI agents need access not only to general knowledge but also to our specific datasets. This is where RAG (Retrieval-Augmented Generation) comes in. In a client project, while building a knowledge base for a bank's internal platform, I used a RAG architecture to ensure LLMs had access to accurate and up-to-date information. We can do this with n8n without writing any code.

RAG Integration

The basic idea for RAG is to retrieve the most relevant information from our own data sources before asking the LLM a question, and then adding this information to the prompt.

  1. Data Source: Your internal documents (PDFs, text files, database records) should be embedded in a vector database (e.g., Pinecone, Weaviate, Qdrant, or even PostgreSQL's pg_vector extension). n8n has direct integration nodes for these vector databases. On my end, I usually prefer PostgreSQL with pg_vector because using a technology I already have eliminates additional costs.

  2. Generating Embeddings: Before uploading your documents to the vector database, you need to create their "embeddings" (numerical vector representations). You can use nodes like "OpenAI Embeddings" or "Cohere Embeddings" for this.

  3. Vector Search: When a question comes in (e.g., from a Webhook trigger), you search for the most relevant document chunks related to the question using the appropriate vector database node from the "Vector Store" category.

  4. Enriching the Prompt: You enrich the prompt by adding the information from the search results (usually text snippets) to the LLM node's User Prompt. For example:

    Here is some relevant information from our internal knowledge base:
    ---
    {{ $node["Vector Search"].json["results"] }}
    ---
    Based on the information above, answer the following question:
    {{ $json.query }}
    

This way, the LLM can generate more accurate and contextual answers by being fed not only general information but also your corporate knowledge.

Multi-LLM Provider Integration and Fallback

Relying on a single LLM provider can be risky in terms of both cost and performance. Different providers offer different models, and the costs, speeds, and performances of these models vary. With n8n, I can integrate multiple LLM providers and set up fallback mechanisms to switch to another provider based on the situation or if one provider fails. I typically use providers like Groq, Gemini Flash, and OpenRouter together. Groq stands out for its speed, Gemini Flash might be more affordable, and OpenRouter offers various models through a single API.

Example of a multi-LLM flow:

  1. Main LLM Attempt: First, I use my primary preferred LLM provider (e.g., Groq).
  2. Error Checking: If an error occurs from the Groq node (e.g., API timeout or rate limit), I check this condition with an "IF" node.
  3. Fallback LLM: In case of an error, I switch to another LLM node (e.g., Gemini Flash via OpenRouter) from the "true" branch of the "IF" node.
  4. Result Merging: I can then merge the results from both LLMs with a "Merge" node and present them as a single output to the rest of the flow.

This architecture is vital for ensuring continuity, especially in critical workflows. I use this fallback mechanism in the AI-based predictions for financial calculators in one of my side products. This way, if there's an issue with one provider, the user experience isn't interrupted.

Operational Details: Security, Monitoring, and Maintenance

Setting up a self-hosted system brings with it operational responsibilities. I take some basic precautions to ensure n8n runs smoothly and securely.

Security Measures

  • Nginx Reverse Proxy and SSL: Instead of exposing n8n directly to the internet, I place an Nginx reverse proxy in front of it. With Nginx, I perform SSL termination (free with Let's Encrypt) and add basic security layers. For example, I use rate limiting to create the first line of defense against DDoS attacks. I also set HTTP security headers like X-Content-Type-Options and X-Frame-Options.

    Example Nginx configuration:

    server {
        listen 80;
        server_name automations.mysite.com;
        return 301 https://$host$request_uri;
    }
    
    server {
        listen 443 ssl http2;
        server_name automations.mysite.com;
    
        ssl_certificate /etc/letsencrypt/live/automations.mysite.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/automations.mysite.com/privkey.pem;
    
        # Security headers
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-Content-Type-Options "nosniff";
        add_header X-XSS-Protection "1; mode=block";
    
        location / {
            proxy_pass http://localhost:5678;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            # Rate limiting example
            # limit_req zone=one burst=5 nodelay;
        }
    }
    
  • Fail2ban: I use fail2ban to prevent brute-force attacks on my server via SSH. I can also track failed login attempts to n8n's web interface from logs and block them with fail2ban. For this, I centralize n8n logs with journald and write a custom jail rule for fail2ban.

    Example fail2ban jail rule (for n8n):

    [n8n-auth]
    enabled = true
    port = http,https
    filter = n8n-auth
    logpath = /var/log/syslog # Or where logs from journald are stored
    maxretry = 5
    bantime = 3600
    

    And filter.d/n8n-auth.conf file:

    [Definition]
    failregex = .*n8n.*authentication failed for user.*<HOST>.*
    ignoreregex =
    

    This rule detects failed login attempts by searching for the "authentication failed for user" pattern in n8n logs and blocks the IP address for one hour.

  • Kernel Module Blacklist: To protect against security vulnerabilities, I blacklist kernel modules I don't use. Taking such precautions is especially important when modules like algif_aead have old CVEs (like CVE-2026-31431). This improves overall system security.

Monitoring and Maintenance

  • Log Management: I centralize all Docker container logs with journald. This is crucial for troubleshooting and security auditing. In case of an error, I monitor live logs with journalctl -u docker.service -f or check past logs with journalctl -u docker.service --since "1 hour ago".
  • Resource Monitoring: I keep memory and CPU usage under control by specifying cgroup limits in the Docker Compose file. Additionally, I monitor n8n's own metrics (enabled with N8N_METRICS_ENABLED=true) and the server's overall resource usage with tools like Prometheus and Grafana. I particularly track database and cache server metrics to detect issues like PostgreSQL WAL bloat or Redis OOM eviction policy proactively.
  • Backup: I take regular backups for the PostgreSQL database. I automate this process with the pg_dump command or a backup tool. n8n workflows can also be exported as a JSON file, which helps in recovery scenarios.

⚠️ Don't Forget Your Responsibilities

All security and maintenance responsibilities for a self-hosted system lie with you. Tasks such as regularly applying security patches, monitoring logs, and performing backups are critically important. The "it'll be fine" mentality may not work in disaster scenarios.

Conclusion and Next Steps

Setting up my own AI automations self-hosted with n8n has provided me with both flexibility and cost advantages. The ability to create complex agent flows without writing code, use my own data with RAG, and integrate different LLM providers is a huge plus. I use these types of AI automations in many different scenarios, such as production planning in a manufacturing ERP, prioritizing customer support emails on an e-commerce site, or making financial predictions in my own side product.

This setup was a project that brought together my experience in many areas, not just AI integration, but also system administration, network security (Nginx, fail2ban), and database optimization (PostgreSQL). Although I initially encountered insidious issues like MTU/MSS mismatches or DNS negative caching, I debugged and resolved them step-by-step.

If you also want to build your own AI automations but don't want to write code and data control is a priority for you, a self-hosted n8n setup is definitely worth trying. As a next step, I'm exploring how to use "agent patterns" (planning, tool use, memory) more effectively within n8n to make these AI agents even smarter. Perhaps I'll cover this topic in my next post.