SSD Grow


Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Use Docker & Nginx to Host Multiple Websites on a Single-Performance Linux VPS


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Table of Content


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Docker is a fantastic tool for running multiple services on a single-performance Linux VPS without interference. For example, you can host one website built on WordPress and another on Ghost or a flat-file CMS. However, containerizing software often raises the question: How do you host multiple websites, each in a separate Docker container, from one Performance Linux VPS? By default, Docker services listen on port 80, leading to conflicts for incoming traffic. While you can change the listening port, no one wants to type in coolwebsite.com:34567. Instead, you can use Nginx to route traffic from coolwebsite.com to a container listening on port 34567 and traffic from anothercoolwebsite.net to a container on port 45678.

Nginx-proxy solves this problem by listening on port 80 (the standard HTTP port) and forwarding incoming requests to the appropriate container. This process, known as reverse proxying, leverages Docker’s VIRTUAL_HOST variable. In this tutorial, we’ll set up nginx-proxy and demonstrate how to use Docker and Nginx to route traffic to different containers, enabling you to host multiple websites on different domains from a single Performance Linux VPS.


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87
An Ubuntu/Debian/CentOS server with Docker installed A non-root user with sudo privileges.

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Step 1. Starting up nginx-proxy to hook Docker and Nginx together


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

To get started, let’s start up the nginx-proxy container. This can be accomplished either by a single docker command or using docker-compose. Let’s cover both.

To get started, create a Docker network

Before we get started, either way, we need to first create a Docker network that we will use to bridge all of these containers together.


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

$ docker network create nginx-proxy


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

From now on, we need to ensure that we’re always adding new containers to the nginx-proxy Docker network.


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87
Installing nginx-proxy with Docker

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

$ docker run -d -p 80:80 --name nginx-proxy --net nginx-proxy -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87
Installing nginx-proxy with docker-compose

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

First, create a new docker-compose.yml file in the directory of your choosing (one titled nginx-proxy is a good idea), and copy in the following text:


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Version: "3"
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- "80:80"
volumes:
-/var/run/docker.sock:/tmp/docker.sock:ro


networks:
default:
external:
name: nginx-proxy


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Then run the following docker-compose command to get started.


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

$ docker-compose up -d


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87
Nginx-proxy works to host multiple websites

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

As shown in both code options, the container listens on port 80 and exposes the same port inside the container, allowing all incoming traffic to flow through Nginx.

You might wonder about the purpose of the line /var/run/docker.sock:/tmp/docker.sock. This line grants any container access to the host’s Docker socket, which contains information about Docker events, such as container creation or shutdown.

This setup enables nginx-proxy to detect new containers via the socket, automatically generate the necessary configuration files to route traffic, and restart Nginx to apply the changes immediately. nginx-proxy identifies containers with the VIRTUAL_HOST variable enabled, which is crucial for our setup.

Additionally, the –net nginx-proxy line in the Docker command and the networks: default: external: name: nginx-proxy block in the docker-compose.yml file are important. They ensure that all containers communicate over the designated Docker network.


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Step 2. Adding a container to the proxy


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Now that have nginx-proxy running, can start adding new containers, which will be automatically picked up and configured for. As covered in the last Docker tutorial, and since it’s an easy implementation to try out, let’s use WordPress as an example.


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87
Using Docker  

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Starting a WordPress container with a basic configuration is quite easy.


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

$ docker run -d --name blog --expose 80 --net nginx-proxy -e
VIRTUAL_HOST=blog.DOMAIN.TLD wordpress


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87
Take note of a few elements here. –expose 80 will allow traffic to flow into the container on port 80. –net nginx-proxy ensures we’re using the Docker network we created earlier. Finally, -e VIRTUAL_HOST=blog.DOMAIN.TLD flags nginx-proxy to create the proxy information and direct traffic arriving to the correct domain.

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Using docker-compose


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Start by creating a ‘docker-compose.yml’ file in an empty directory and copying in the following.


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

$ version: "3"

services:
db_node_domain:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: PASSWORD
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: PASSWORD
container_name: wordpress_db

wordpress:
depends_on:
- db_node_domain
image: wordpress:latest
expose:
- 80
restart: always
environment:
VIRTUAL_HOST: blog.DOMAIN.TLD
WORDPRESS_DB_HOST: db_node_domain:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: PASSWORD
container_name: wordpress
volumes:
db_data:

networks:
default:
external:
name: nginx-proxy


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Again, take note of the expose and environment: VIRTUAL_HOST options within the file. Also, the networks option at the bottom is necessary to allow this container to “speak” with nginx-proxy.

Also, take note of the line that begins with db_node_domain. If you are going to host multiple WordPress blogs using this method, you need to create unique database names for each. You should replace db_node_domain with your preferred naming scheme. You also need to update two other fields with this chosen name. First:


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

$ ddepends_on:
- db_node_domain


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

And second:


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

$ WORDPRESS_DB_HOST: db_node_domain:3306


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Once the configuration file is set up, you can run the docker-compose up -d command. As long as your DNS is set up to route traffic properly, things should work correctly.

From here, you can start up any number of additional WordPress sites—or any type of service, for that matter—and have them automatically added to the nginx-proxy network. This Docker and Nginx configuration is pretty infinitely extensible, limited only by the Performance Linux VPS resources available to you.


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Additional resources to host multiple websites


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Be sure to check out the extensive documentation for nginx-proxy to learn more about configuring more complex setups between Docker and Nginx, such as those involving SSL, multiple ports, or multiple networks. Although haven’t tested it yet, there’s a companion tool called letsencrypt-nginx-proxy-companion that automatically creates and renews Let’s Encrypt certificates directly alongside the proxy itself.


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Conclusion


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Using Docker and Nginx to host multiple websites on a high-performance linux vps is an efficient and scalable solution. By leveraging Docker’s containerization and Nginx’s reverse proxy capabilities, you can manage and route traffic to various services seamlessly. This setup not only maximizes the use of your Performance Linux VPS resources but also simplifies the deployment and management of multiple websites. Whether you’re running WordPress, Ghost, or other CMS platforms, Docker and Nginx provide a robust framework for handling multiple sites with ease


Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Category


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Share


Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Related Articles


Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87

Warning: Undefined array key "_border_border" in /www/wwwroot/ssdgrow.com/wp-content/plugins/elementor/includes/conditions.php on line 87