How to Host Multiple Websites on One VPS with Docker and Nginx (2026 Guide)
Can you host multiple websites on a single VPS without purchasing separate hosting plans for every project? Yes. You can run multiple websites on one VPS using Docker containers and Nginx as a reverse proxy. This archi
Can you host multiple websites on a single VPS without purchasing separate hosting plans for every project?
Yes. You can run multiple websites on one VPS using Docker containers and Nginx as a reverse proxy.
This architecture allows each website to operate in an isolated environment while sharing the same server resources. It works particularly well for WordPress websites, PHP applications, Node.js projects, Python applications, landing pages, and business websites.
In this guide, you'll learn how to configure Docker, connect multiple websites through Nginx, enable HTTPS, improve server security, and manage resources efficiently.
- Why Host Multiple Websites on One VPS?
Hosting multiple websites on one VPS can reduce infrastructure costs and simplify server management.
Instead of purchasing separate hosting accounts, you can use one VPS to manage several independent applications.
Key advantages include:
Lower monthly hosting costs.
Centralized server management.
Independent application environments.
Full root access and configuration control.
Flexible resource allocation.
Easier deployment and maintenance.
Ability to scale when traffic increases.
However, your VPS must have sufficient CPU, RAM, storage, and network capacity for all hosted websites.
- Why Use Docker and Nginx Together?
Docker and Nginx perform different but complementary functions.
Docker: Runs each website inside an isolated container with its own application environment and dependencies.
Nginx: Works as a reverse proxy, receiving incoming requests and forwarding visitors to the correct website based on the requested domain.
For example:
Website
Technology
Container
example1.com
WordPress
Container 1
example2.com
Node.js
Container 2
example3.com
Laravel
Container 3
example4.com
Python
Container 4
All websites can share one VPS while maintaining separate application environments.
- What Do You Need Before Starting?
Prepare the following:
Ubuntu 22.04 or 24.04 VPS.
Docker Engine.
Docker Compose plugin.
Nginx reverse proxy.
Registered domain names.
SSH access.
Sufficient RAM and CPU resources.
For a small number of lightweight websites, 2 GB RAM may work. However, 4 GB or more is a better starting point for multiple applications. Actual requirements depend on traffic and workload.
- Install Docker on Ubuntu VPS
First, update your server:
sudo apt update
sudo apt upgrade -y
Install Docker using the official Docker installation instructions for Ubuntu.
Verify the installation:
docker --version
Check Docker Compose:
docker compose version
Make sure Docker starts automatically:
sudo systemctl enable --now docker
- Create a Docker Network
Create a shared network so Nginx can communicate with your website containers.
docker network create web-network
This network allows containers to communicate internally without exposing every application port publicly.
- Deploy Multiple Websites with Docker Compose
Create a directory for your projects:
mkdir -p ~/websites
cd ~/websites
Create a Docker Compose configuration:
services:
site1:
image: nginx:alpine
container_name: website_one
restart: unless-stopped
networks:
- web-network
site2:
image: nginx:alpine
container_name: website_two
restart: unless-stopped
networks:
- web-network
networks:
web-network:
external: true
Start the containers:
docker compose up -d
This is a basic demonstration. For production, replace the example images with your actual website applications and configure their document roots, databases, environment variables, and persistent storage.
- Configure Nginx as a Reverse Proxy
Nginx directs visitors to the correct application based on their domain name.
For example, create a configuration for the first website:
server {
listen 80;
server_name example1.com www.example1.com;
location / {
proxy_pass http://site1:80;
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;
}
}
For the second website:
server {
listen 80;
server_name example2.com www.example2.com;
location / {
proxy_pass http://site2:80;
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;
}
}
Connect Nginx to the same Docker network and validate its configuration before reloading.
Important: The service names must be resolvable within the shared Docker network. If Nginx runs directly on the VPS instead, use the appropriate published localhost ports instead of Docker service names.
- Configure DNS for Every Website
Point each domain to your VPS public IP address.
Example:
Domain
DNS Record
Value
example1.com
A
VPS IP
example2.com
A
VPS IP
example3.com
A
VPS IP
You should also configure the appropriate www records.
Allow time for DNS changes to propagate.
- Enable Free SSL Certificates
HTTPS protects data transferred between visitors and your websites.
You can use Let's Encrypt with Certbot to obtain free SSL certificates.
For an Nginx installation directly on Ubuntu:
sudo apt install certbot python3-certbot-nginx
Request a certificate:
sudo certbot --nginx -d example1.com -d www.example1.com
Repeat for other domains.
If you use containerized Nginx, configure certificate storage and renewal for that architecture rather than assuming the host Nginx plugin will configure your container automatically.
- How Much VPS Resources Do Multiple Websites Need?
Your server requirements depend on application complexity, traffic, database usage, and caching.
Here is a general starting point:
VPS Resources
Suitable Workload
2 GB RAM
A few lightweight websites
4 GB RAM
Several small websites
8 GB RAM
Multiple business websites and applications
16 GB RAM
Larger applications and heavier workloads
These are planning estimates, not guaranteed capacity limits. Monitor actual resource consumption before adding more websites.
- Security Best Practices
Running multiple websites on one VPS requires proper security management.
Follow these recommendations:
Configure UFW firewall rules.
Use SSH key authentication.
Disable password-based SSH login where practical.
Keep Docker and Ubuntu updated.
Avoid exposing unnecessary container ports.
Use HTTPS for all websites.
Store application secrets securely.
Use separate database credentials.
Monitor server logs.
Schedule regular backups.
Apply appropriate container permissions.
Remember that Docker container isolation is not a replacement for complete server security.
- Performance Optimization
To improve website performance:
Enable Nginx compression.
Configure browser caching.
Optimize images and static files.
Use Redis where appropriate.
Optimize database queries.
Consider a CDN for global visitors.
Monitor CPU and RAM usage.
Remove unused Docker images and containers.
Configure application-level caching.
Upgrade VPS resources when necessary.
- Docker vs Traditional Hosting: Which Is Better?
Feature
Docker + Nginx
Traditional Shared Hosting
Application Control
High
Limited
Root Access
Yes, with VPS
Usually No
Application Isolation
Container-based
Provider-dependent
Multiple Technologies
Flexible
Plan-dependent
Server Customization
Extensive
Limited
Resource Management
Configurable
Provider-managed
Maintenance
User-managed
Provider-managed
Docker-based VPS hosting is ideal for developers who need flexibility and control. Traditional shared hosting may be more suitable for beginners who prefer managed infrastructure.
Frequently Asked Questions (FAQ)
- Can I host multiple websites on one VPS?
Yes. You can host multiple websites on one VPS using Docker containers and an Nginx reverse proxy. Each website can run independently while sharing the VPS CPU, RAM, storage, and network resources.
- How many websites can I run on a single VPS?
There is no fixed limit. The number depends on available RAM, CPU, storage, application requirements, and visitor traffic. Lightweight static websites can run in larger numbers than resource-intensive WordPress or eCommerce applications.
- Is Docker better than traditional hosting for multiple websites?
Docker provides more control, application isolation, and flexibility than traditional shared hosting. However, it requires server administration knowledge. Traditional hosting is often easier for users who do not want to manage infrastructure.
- Why should I use Nginx with Docker?
Nginx acts as a reverse proxy that routes incoming requests to the correct Docker container based on domain names. It can also handle HTTPS termination, compression, caching, and other web traffic management tasks.
- Can I host WordPress and Node.js on the same VPS?
Yes. Docker allows WordPress and Node.js to run in separate containers on the same VPS. Each application can use its own dependencies and configuration without requiring separate physical servers.
- Do multiple websites on one VPS share the same IP address?
Generally, yes. Multiple domains can point to the same public VPS IP address. Nginx identifies the requested domain and routes the request to the appropriate website.
- Do I need a separate SSL certificate for each website?
Each domain should have valid HTTPS coverage. You can obtain separate Let's Encrypt certificates or use a certificate that covers multiple domains. Nginx can manage HTTPS connections for all hosted websites.
- Is hosting multiple websites on one VPS secure?
It can be secure when configured properly. Use container isolation, firewall rules, SSH keys, regular updates, restricted port access, HTTPS, secure credentials, and reliable backups. A compromised VPS can still affect multiple websites.
- Can I host multiple WordPress websites using Docker?
Yes. You can run multiple WordPress installations in separate containers with separate databases and persistent storage. This makes it easier to manage different WordPress projects on one VPS.
- What happens if my VPS runs out of RAM?
When memory becomes insufficient, applications may slow down, containers may restart, or the operating system may terminate processes. Monitor memory usage and optimize applications or upgrade your VPS when necessary.
- Can I add more websites to my VPS later?
Yes. You can deploy additional Docker containers, configure new Nginx server blocks, and point new domains to your VPS. Make sure your server has enough resources to handle the additional workload.
- Where can I get a VPS for hosting multiple websites?
Choose a VPS provider based on CPU performance, RAM, SSD or NVMe storage, network quality, server location, backup options, and technical support. Oudel offers VPS hosting options for users who need a server environment for website deployment and application management.
Explore Oudel VPS Hosting to learn more about available hosting options.
*Conclusion
*
Hosting multiple websites on one VPS using Docker and Nginx is a flexible solution for developers, businesses, and website owners.
Docker keeps applications separated, while Nginx directs incoming traffic to the correct website. With proper DNS configuration, SSL certificates, resource monitoring, and security practices, you can manage multiple websites from a centralized server environment.
The key is choosing the right VPS resources and maintaining a secure, well-organized deployment.
Ready to host multiple websites? Explore Oudel VPS Hosting and find a suitable VPS environment for your next project.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.