Skip to main content

Confluence - Docker Compose Stack with Nginx Reverse Proxy

288 words·
Confluence Docker-Compose Nginx PostgreSQL
Table of Contents

Confluence Docker Compose Stack
#

DockerHub: https://hub.docker.com/r/atlassian/confluence-server


Folder Structure
#

# Create folder structure
sudo mkdir -p /opt/confluence/data/{db,logs,server,shared-home} && cd /opt/confluence

# Change permissions
sudo chown -R 2002:2002 /opt/confluence/data/{logs,server,shared-home}

Environment File
#

# Create environment file
sudo vi .env

# .env
ATL_PROXY_NAME=confluence.jklug.work
ATL_PROXY_PORT=443
ATL_TOMCAT_SCHEME=https
ATL_TOMCAT_SECURE=true

ATL_JDBC_URL=jdbc:postgresql://db:5432/confluence
ATL_JDBC_USER=confluence
ATL_JDBC_PASSWORD=my-confluence-password # Define DB PW
ATL_DB_TYPE=postgresql

POSTGRES_HOST=db
POSTGRES_PORT=5432
POSTGRES_USER=confluence
POSTGRES_DB=confluence
POSTGRES_PASSWORD=my-confluence-password # Define DB PW

CONFLUENCE_SHARED_HOME=/var/atlassian/application-data/confluence/shared-home
JVM_MINIMUM_MEMORY=2048

Docker Compose File
#

# Create Docker Compose file
vi docker-compose.yml
version: '3'

services:
  server:
    image: "atlassian/confluence:latest"
    container_name: confluence-server
    env_file:
      - .env
    ports:
      - "8090:8090"
      - "8091:8091"
    volumes:
      - ./data/server:/var/atlassian/application-data/confluence
      - ./data/shared-home:/var/atlassian/application-data/confluence/shared-home
      - ./data/logs:/opt/atlassian/confluence/logs
    links:
      - db
    depends_on:
      - db

  db:
    image: "postgres:12"
    container_name: confluence-db
    env_file:
      - .env
    volumes:
      - ./data/db:/var/lib/postgresql/data

Note: The ./data/shared-home directory is only necessary when running Confluence in Data Center mode / deploying it as a cluster across multiple nodes. The directory should be located on an NFS share that can be accessed from all nodes.


Create / Start Docker Stack
#

# Create / start Docker Stack
docker compose up -d

# Check logs
docker-compose logs -f

Reverse Proxy
#

Certbot
#

# Install Certbot
sudo apt install certbot

# Create certificate
sudo certbot certonly --standalone -d confluence.jklug.work

Nginx
#

# Install nginx
sudo apt install nginx

# Copy default config
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/confluence.jklug.work
# Edit config
sudo vi /etc/nginx/sites-available/confluence.jklug.work

# confluence.jklug.work
server {
    listen 443 ssl;
    server_name confluence.jklug.work;

    ssl_certificate         /etc/letsencrypt/live/confluence.jklug.work/fullchain.pem;
    ssl_certificate_key     /etc/letsencrypt/live/confluence.jklug.work/privkey.pem;


    location / {
        proxy_pass http://127.0.0.1:8090/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
# Disable default config
sudo rm /etc/nginx/sites-enabled/default

# Enable config
sudo ln -s /etc/nginx/sites-available/confluence.jklug.work /etc/nginx/sites-enabled/

# Restart Nginx
sudo systemctl restart nginx

License
#

Link: https://id.atlassian.com/login?application=mac&continue=https://my.atlassian.com/license/evaluation

  • Create license

  • Paste license in GUI: confluence.jklug.work

  • Select “Non-clustered” for single node setup