Sign inSign up

bai0012/nginx-multi-site

By bai0012

•Updated over 1 year ago

Image
0

195

bai0012/nginx-multi-site repository overview

⁠My Nginx Multi-Site Docker Image

This Docker image hosts multiple web applications using Nginx, each served over a different port with SSL and basic authentication enabled. The following instructions will guide you through setting up and running this image.

⁠Table of Contents

  1. Introduction⁠
  2. Preparation⁠
  3. Nginx Configuration⁠
  4. Basic Authentication⁠
  5. SSL Certificates⁠
  6. Build and Run⁠
  7. Versions⁠
  8. Security Considerations⁠

⁠Introduction

This Docker image is configured to serve multiple static websites using Nginx. The sites included are:

  • A Dark Room
  • Degrees of Lewdity
  • FC Pregmod
  • Sandboxels

Each site is served on a separate port with SSL encryption and requires basic authentication.

⁠Preparation

⁠1. Web Pages

Ensure that the web pages are prepared and located in the following directories within the Docker image:

  • /var/www/adarkroom
  • /var/www/dol
  • /var/www/fc-pregmod
  • /var/www/sandboxels
⁠2. Nginx Configuration

The Nginx configuration is set up to support multiple sites, each with its own server block configuration file located in /etc/nginx/conf.d/.

Example configuration for one site (web1.conf):

server {
    listen      8081 ssl;
    server_name localhost;

    root        /var/www/web1;
    index       index.html;

    ssl_certificate     /etc/nginx/certs/certificate.crt;
    ssl_certificate_key /etc/nginx/certs/private.key;

    ssl_protocols       TLSv1.2 TLSv1.3;
    ssl_ciphers         ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;

    auth_basic          "Restricted Content";
    auth_basic_user_file /etc/nginx/conf.d/.htpasswd;

    location / {
        try_files $uri/ $uri =404;
    }
}

Modify the listen port and root directory for other sites accordingly.

⁠3. Basic Authentication

Create an .htpasswd file on your host machine to enable basic authentication:

htpasswd -c /path/on/host/.htpasswd username
⁠4. SSL Certificates

Place your certificate files on the host machine in a secure directory:

  • your_certificate.crt
  • your_private.key

⁠Build and Run

⁠Building the Docker Image

Build the Docker image using the following command:

docker build -t my-nginx-multi-site .
⁠Running the Docker Container

Run the Docker container with the appropriate port mappings and file mounts:

docker run -d \
  -p 8081:8081 \
  -p 8082:8082 \
  -p 8083:8083 \
  -p 8084:8084 \
  -v /path/on/host/your_certificate.crt:/etc/nginx/certs/certificate.crt:ro \
  -v /path/on/host/your_private.key:/etc/nginx/certs/private.key:ro \
  -v /path/on/host/.htpasswd:/etc/nginx/conf.d/.htpasswd:ro \
  bai0012/nginx-multi-site

⁠Versions

⁠Security Considerations

  • Ensure that .htpasswd and SSL private key files are kept secure and only accessible by authorized personnel.
  • Use strong passwords for basic authentication to prevent unauthorized access.
  • Regularly update your SSL certificates to maintain secure connections.

Tag summary

Content type

Image

Digest

sha256:dc14039b5…

Size

76.1 MB

Last updated

over 1 year ago

docker pull bai0012/nginx-multi-site