# rdiezsj/multisite-with-proxy-and-ssl-docker architecture

> Architecture diagram of the GitHub repository rdiezsj/multisite-with-proxy-and-ssl-docker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rdiezsj/multisite-with-proxy-and-ssl-docker
- Repository: https://github.com/rdiezsj/multisite-with-proxy-and-ssl-docker

## Overview

##### Project type and purpose
- This is a Docker-Compose based multi-site hosting stack.
- Purpose: centrally host multiple web applications (WordPress, DokuWiki) behind an Nginx reverse-proxy with automated Let’s Encrypt SSL.

##### File structure
- Top-level files:
- `.env.example` / `.env` – environment variables (domains, mail, DB creds)
- `docker-compose.yml` – orchestrates all containers
- `vhost/` – per-domain custom Nginx server blocks
- `client_max_upload_size.conf`, `uploads.ini` – upload limits for Nginx & PHP
- `uploads.ini` – PHP upload limits
- `vhost/test1.fake.com`, `vhost/test2.foo.com` – optional custom rewrites
- No “src” code here—this is purely infrastructure.
- Volumes & networks are declared in `docker-compose.yml`.

##### Extract architecture hints from README
- Two sites: test1.fake.com (WordPress+MySQL), test2.foo.com (DokuWiki).
- Shared Nginx proxy + acme-companion for SSL certs.
- Uses one external Docker network (`multisite-net`) and one internal WordPress-MySQL network (`mysqldb1`).

##### Main components
a. External/Infrastructure
- DNS provider resolving `test1.fake.com` and `test2.foo.com` to host IP.
- Public ports 80 and 443 on the Docker host.
b. Docker Host (virtual or physical server)
- Docker Engine & Docker Compose
- External network: `multisite-net`
c. Containers
1. nginx-proxy
- Image: jwilder/nginx-proxy
- Listens on 80/443, mounts Docker socket to auto-generate vhosts.
- Loads per-domain config from `/etc/nginx/vhost.d`.
2. acme-companion
- Image: nginxproxy/acme-companion
- Hooks into nginx-proxy, uses Let’s Encrypt to obtain SSL certificates.
3. WordPress site (`wordpress1`)
- PHP-Apache container with VIRTUAL_HOST & LETSENCRYPT_HOST env vars.
- Connects to MySQL over internal `mysqldb1` network.
- Mounts uploads.ini, WP content volume.
4. MySQL (`mysqldb1`)
- mysql:latest, private internal network.
- Volume for database persistence.
5. DokuWiki (`dokuwiki`)
- linuxserver/dokuwiki, mounts `/config` volume, attaches to `multisite-net`.
d. Volumes
- certs, html, dhparam, acme, mysqldb1, wordpress1, dokuwiki1 for persistence.

##### Relationships & data flows
- DNS → Host Public IP → Ports 80/443 → nginx-proxy
- nginx-proxy → routes HTTP(S) traffic to:
- wordpress1 (via `multisite-net`)
- dokuwiki (via `multisite-net`)
- wordpress1 ↔ mysqldb1 (over internal network `mysqldb1`)
- acme-companion ↔ nginx-proxy & Docker socket (for certificate generation)
- Volumes attached to each container for persistence.

##### Architectural patterns & principles
- Reverse-proxy pattern for multi-tenancy.
- Network segmentation: internal network for DB security.
- 12-factor app style: config via env vars, stateless containers, separate storage volumes.
- Automated certificate provisioning.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Infrastructure
    DNS["DNS Provider"]:::external
    Internet["Internet"]:::external

    DNS -->|resolves test1.fake.com & test2.foo.com| Internet
    Internet -->|80/443| NGINX_PROXY

    %% Docker Host Boundary
    subgraph "Docker Host" 
        direction TB

        %% Networks
        subgraph "multisite-net (external)" 
            direction TB
            NGINX_PROXY["nginx-proxy\n(jwilder/nginx-proxy)"]:::proxy
            ACME["acme-companion\n(nginxproxy/acme-companion)"]:::ssl
            WP["wordpress1\n(PHP-Apache)"]:::app
            DOKU["dokuwiki\n(linuxserver/dokuwiki)"]:::app
        end

        subgraph "mysqldb1-network (internal)" 
            direction TB
            MYSQL["mysqldb1\n(mysql:latest)"]:::db
        end

        %% Volumes
        CERTS(("certs")):::volume
        HTML(("html")):::volume
        DHPARAM(("dhparam")):::volume
        ACME_VOL(("acme")):::volume
        WP_VOL(("wordpress1")):::volume
        DOKU_VOL(("dokuwiki1")):::volume
        DB_VOL(("mysqldb1")):::volume

        %% Network Attachments
        NGINX_PROXY ---|attach to| CERTS
        NGINX_PROXY ---|attach to| HTML
        NGINX_PROXY ---|attach to| DHPARAM
        NGINX_PROXY ---|attach to| ACME_VOL

        ACME ---|uses socket & certs| NGINX_PROXY

        WP ---|mounts| WP_VOL
        WP ---|mounts| uploadsINI
        WP -->|DB queries| MYSQL

        DOKU ---|mounts| DOKU_VOL
    end

    %% Configuration Files
    ENV["Environment Variables\n(.env/.env.example)"]:::config
    COMPOSE["docker-compose.yml"]:::config
    UPLOAD_LIMIT_CFG["client_max_upload_size.conf"]:::config
    PHP_UPLOAD_CFG["uploads.ini"]:::config
    VHOST1["vhost/test1.fake.com"]:::config
    VHOST2["vhost/test2.foo.com"]:::config
    README["README.md"]:::config

    %% File Config Connections
    ENV --> COMPOSE
    COMPOSE --> NGINX_PROXY
    COMPOSE --> ACME
    COMPOSE --> WP
    COMPOSE --> MYSQL
    COMPOSE --> DOKU

    UPLOAD_LIMIT_CFG --> NGINX_PROXY
    PHP_UPLOAD_CFG --> WP

    VHOST1 --> NGINX_PROXY
    VHOST2 --> NGINX_PROXY

    README --> COMPOSE

    %% Click Events
    click ENV "https://github.com/rdiezsj/multisite-with-proxy-and-ssl-docker/blob/master/.env.example"
    click COMPOSE "https://github.com/rdiezsj/multisite-with-proxy-and-ssl-docker/blob/master/docker-compose.yml"
    click UPLOAD_LIMIT_CFG "https://github.com/rdiezsj/multisite-with-proxy-and-ssl-docker/blob/master/client_max_upload_size.conf"
    click PHP_UPLOAD_CFG "https://github.com/rdiezsj/multisite-with-proxy-and-ssl-docker/blob/master/uploads.ini"
    click VHOST1 "https://github.com/rdiezsj/multisite-with-proxy-and-ssl-docker/blob/master/vhost/test1.fake.com"
    click VHOST2 "https://github.com/rdiezsj/multisite-with-proxy-and-ssl-docker/blob/master/vhost/test2.foo.com"
    click README "https://github.com/rdiezsj/multisite-with-proxy-and-ssl-docker/blob/master/README.md"

    %% Styles
    classDef external fill:#E0E0E0,stroke:#999,stroke-width:1px
    classDef proxy fill:#AEDFF7,stroke:#0077C8,stroke-width:2px
    classDef ssl fill:#A3D7A1,stroke:#2E7D32,stroke-width:2px
    classDef app fill:#C8E6C9,stroke:#388E3C,stroke-width:2px
    classDef db fill:#FFE082,stroke:#FBC02D,stroke-width:2px
    classDef volume fill:#F5F5F5,stroke:#BDBDBD,stroke-dasharray: 2 2
    classDef config fill:#FFF9C4,stroke:#FBC02D,stroke-width:1px
```
