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

推荐订阅源

S
Secure Thoughts
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Heimdal Security Blog
SecWiki News
SecWiki News
H
Hacker News: Front Page
N
News | PayPal Newsroom
L
LINUX DO - 最新话题
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
AI
AI
C
Cybersecurity and Infrastructure Security Agency CISA
Scott Helme
Scott Helme
PCI Perspectives
PCI Perspectives
S
Securelist
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Cyberwarzone
Cyberwarzone
A
Arctic Wolf
Forbes - Security
Forbes - Security
T
Tor Project blog
Spread Privacy
Spread Privacy
WordPress大学
WordPress大学
I
Intezer
Martin Fowler
Martin Fowler
Help Net Security
Help Net Security
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Cisco Talos Blog
Cisco Talos Blog
Latest news
Latest news
博客园 - 司徒正美
W
WeLiveSecurity
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
V2EX
P
Palo Alto Networks Blog
Google DeepMind News
Google DeepMind News
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
V
Vulnerabilities – Threatpost
Jina AI
Jina AI
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
Simon Willison's Weblog
Simon Willison's Weblog
Project Zero
Project Zero
T
Threatpost
P
Privacy International News Feed
人人都是产品经理
人人都是产品经理
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - Franky
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research

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
Nginx Reverse Proxy: Managing Multiple Docker Services on a Single VPS
Mustafa ERBA · 2026-05-11 · via DEV Community

I manage over 13 Docker containers on my own VPS. These include my projects like hesapciyiz.com, islistesi.com, this blog site, and several background services. Exposing each one to the internet using separate ports is not very practical, neither for security nor for management.

The question of how to publish so many services on a single IP address using standard ports like 80 and 443 initially gave me a lot of thought. The solution lay in migrating the Nginx reverse proxy architecture, which I've been using for years, to a Docker environment. In this post, I will explain step-by-step how I set up this structure and the experiences I gained during this process.

Why is Managing Multiple Services on a Single VPS a Problem?

When you want to run multiple web applications on a single server, you encounter a fundamental problem: port conflicts. Ports 80 for HTTP and 443 for HTTPS are standard, and it's not possible for each service to directly listen on these ports. Only one process on the server can use these ports at a time.

When I first encountered this situation, I tried assigning each service a different port (e.g., site1.com:3000, site2.com:4000). However, this resulted in a poor user experience and created additional complexity in areas like SSL certificate management. As my projects grew, I realized this approach was unsustainable and began searching for a more centralized solution.

The Fundamentals of Nginx Reverse Proxy

Nginx reverse proxy acts as a gatekeeper layer to solve this complex situation. It first receives all incoming HTTP/HTTPS requests, then checks the domain name (Host header) the request came from and forwards it to the relevant Docker container. This way, only Nginx's ports 80 and 443 are exposed to the outside world, while the internal Docker services continue to run on their own private ports.

Thanks to this structure, I can manage SSL certificates from a single point (on Nginx). At the same time, I can achieve performance improvements by utilizing Nginx's caching capabilities in conjunction with CDN services like Cloudflare. In essence, Nginx becomes not just a router for me, but also a performance and security layer.

My Nginx + Docker Environment Setup

On my own VPS, I run Nginx inside a Docker container. This provides me with isolation and allows me to easily manage Nginx configurations and dependencies. Below, you will find the main steps and important details of this setup.

ℹ️ Why Nginx Inside a Docker Container?

Running Nginx inside Docker instead of installing it directly on the host system prevents dependency conflicts, allows you to easily test different Nginx versions, and helps you keep your Nginx configurations under version control alongside your application. This isolation is especially valuable for someone like me managing over 13 containers.

Docker Network Structure

To enable secure and name-based communication between the Nginx container and other application containers, creating a dedicated Docker network is critical. This allows containers to reach each other by name rather than IP addresses.

docker network create nginx-proxy-net

Enter fullscreen mode Exit fullscreen mode

With this command, I create a bridge network named nginx-proxy-net. I connect all my web application containers and the Nginx container to this network. This way, Nginx can reach my application with a simple expression like http://my_app_container_name:3000 in the proxy_pass directive.

Running the Nginx Container

I typically use a docker-compose.yml file to run the Nginx container. This allows me to mount Nginx configuration files from my host system and manage port mappings and network connections from a single place.

Here's a simple docker-compose.yml example:

version: '3.8'

services:
  nginx:
    image: nginx:latest
    container_name: nginx-proxy
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./nginx/conf.d:/etc/nginx/conf.d:ro
      - ./certbot/conf:/etc/letsencrypt
      - ./certbot/www:/var/www/certbot
    networks:
      - nginx-proxy-net
    command: "/bin/sh -c 'while :; do sleep 6h & wait $!; nginx -s reload; done & nginx -g \"daemon off;\"'"

networks:
  nginx-proxy-net:
    external: true

Enter fullscreen mode Exit fullscreen mode

In this configuration, Nginx's main configuration file (nginx.conf) and the virtual host configurations (conf.d) I keep separately for each domain are read from my host system. Additionally, I mount the letsencrypt directory for SSL certificates automatically obtained with Certbot. The command line ensures that Nginx reloads its configuration at regular intervals, which is important for automatically activating new certificates.

SSL Certificate Management (with Certbot)

SSL certificates are indispensable nowadays. I generally use Let's Encrypt and Certbot. I also run Certbot as a separate Docker container and share the same letsencrypt and certbot/www directories with the Nginx container.

💡 Certificate Renewal Automation

Running Certbot regularly with cron or systemd.timer ensures that your certificates do not expire. The nginx -s reload part in the command line of my nginx-proxy container is critical for Nginx to start using a new certificate once Certbot obtains it.

To obtain the initial certificate, I typically use the command certbot certonly --webroot -w /var/www/certbot -d domain.com. Then, I update my Nginx configuration to use this certificate.

Configuring Services with Nginx

I create a separate .conf file for each Docker service within Nginx's conf.d directory. This keeps the configuration organized and means that when I want to add a new service, I only need to add its corresponding file.

Example Configuration for an Application (Astro Blog)

This blog site also runs within a Docker container on my VPS. Here's a simplified version of the blog.mustafaerbay.com.conf file:

server {
    listen 80;
    server_name blog.mustafaerbay.com;

    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }

    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl http2;
    server_name blog.mustafaerbay.com;

    ssl_certificate /etc/letsencrypt/live/blog.mustafaerbay.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/blog.mustafaerbay.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/blog.mustafaerbay.com/chain.pem;

    include /etc/nginx/snippets/ssl-params.conf; # My common SSL settings

    location / {
        proxy_pass http://blog_app_container_name:3000; # The port where the application is running
        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;
        proxy_redirect off;
    }

    # Cache-Control override for Astro's static assets
    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|webp|woff2|woff|ttf|eot)$ {
        expires 1y;
        add_header Cache-Control "public, max-age=31536000, immutable";
        proxy_pass http://blog_app_container_name:3000;
        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;
        proxy_redirect off;
    }
}

Enter fullscreen mode Exit fullscreen mode

In this configuration, I automatically redirect requests coming from port 80 to port 443. After defining my SSL certificates, I forward all requests to the / path to the 3000 port of the Docker container named blog_app_container_name. The proxy_set_header directives ensure that the application receives the correct Host, IP, and protocol information.

Adding Multiple Applications

When I want to add a new application, I essentially follow the same steps:

  1. I connect the application as a Docker container to the nginx-proxy-net network.
  2. I create a new domain.com.conf file for the application and add it to the conf.d directory.
  3. I send a docker exec nginx-proxy nginx -s reload command to the Nginx container to reload the configuration.

With this method, I can seamlessly publish different projects like hesapciyiz.com, islistesi.com, and spamkalkani.com on the same physical server through the same Nginx reverse proxy. Each has its own domain name, and Nginx directs the request to the correct container based on the Host header.

Common Problems and Their Solutions

Of course, I've encountered some problems while setting up and managing this structure. Field experience is partly about learning from these mistakes.

Nginx Configuration Errors

It's very easy to make a syntax error in Nginx configuration files. A forgotten semicolon (;) or an incorrect directive can prevent Nginx from starting or cause it to malfunction.

⚠️ Nginx Config Test

I always use the nginx -t command before deploying an Nginx configuration. This helps me detect syntax errors and logical issues in the configuration file in advance. If you are inside a Docker container, you can run it as docker exec nginx-proxy nginx -t.

If Nginx cannot start or doesn't work as expected, the first place I look is the docker logs nginx-proxy output. The error messages here usually directly indicate the source of the problem.

Docker Network Communication Issues

Sometimes Nginx cannot reach the target Docker container via proxy_pass. This usually stems from the following reasons:

  • Incorrect Container Name: Using the wrong container name in the proxy_pass directive.
  • Different Networks: The Nginx and application containers not being on the same Docker network. On my VPS, I once connected an application container to a different network, and Nginx naturally returned a "upstream timed out" error.
  • Application Port: Specifying the wrong port that the application is listening on within Docker (e.g., writing 8080 instead of 3000).

In such cases, I check which networks the container is connected to and its IP address using the docker inspect <container_name> command. I also test if I can reach the application container by running curl http://<app_container_name>:<port> from within the Nginx container.

Cache and Header Management (with Cloudflare)

Sometimes I need to fine-tune Cloudflare's cache for my Astro sites. Astro can default to returning headers like Cache-Control: public, max-age=0, must-revalidate, which causes Cloudflare to always go to the origin.

To overcome this, I add specific Cache-Control headers for static assets in the Nginx configuration. As shown in the Astro blog example above, for URLs with file extensions like .js, .css, .png, I ensure Nginx adds the expires 1y; and add_header Cache-Control "public, max-age=31536000, immutable"; headers. This way, Cloudflare can cache these assets for a long time, and fewer requests reach the server.

Performance and Security Tips

I don't just use Nginx as a reverse proxy; I also make some adjustments to improve my server's performance and security.

Nginx Worker Settings

The number of worker_processes Nginx uses should be adjusted based on your server's CPU core count. I generally use worker_processes auto;, which allows Nginx to automatically detect the number of CPU cores. worker_connections determines how many concurrent connections each worker process can handle. On my VPS, I usually keep this value at 1024 or 2048.

Security Headers

I add some HTTP security headers through Nginx to make my web applications more secure. These headers help prevent browsers from exploiting certain security vulnerabilities.

Here are some examples I keep in a file like snippets/security-headers.conf:

add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

Enter fullscreen mode Exit fullscreen mode

By including this snippets file in each of my server blocks, I automatically add these headers to all my sites.

Rate Limiting

Spam bots and malicious requests have always been a problem for me, especially for my API-based services like spamkalkani.com. Nginx's rate limiting features are a great tool for limiting requests from specific IP addresses.

# Add to the http block in nginx.conf
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=5r/s;

Enter fullscreen mode Exit fullscreen mode

The configuration above defines a limit allowing 5 requests per second per IP address. I can then apply this to a location block:

location /api/ {
    limit_req zone=mylimit burst=10 nodelay;
    proxy_pass http://api_app_container_name:3001;
    # ... other proxy settings
}

Enter fullscreen mode Exit fullscreen mode

This helps me keep bot requests to spamkalkani.com's API under control. Last month, my CPU spiked to 90% due to a bot attack; after implementing this setting, I could finally breathe easy.

Conclusion

Managing multiple web services on a single VPS using Nginx reverse proxy and Docker has been a cost-effective and highly organized solution for me. With this setup, I can efficiently utilize my server resources, easily scale my services, and manage security and performance from a central point.

I had a lot of headaches setting up this system, especially with inter-container network issues at first. But now it works like a charm, and adding a new project only takes a few minutes. Do you have a different approach you use for managing multiple services on a single VPS? Or did you get stuck somewhere while applying the steps in this guide? We can discuss it in the comments. Perhaps in my next post, I'll explain how I added monitoring on top of this structure.