Skip to main content

Jira - Docker Compose Stack with Nginx Reverse Proxy

203 words·
Jira Docker-Compose Nginx PostgreSQL
Table of Contents

Jira Docker Compose Stack
#

Folder Structure
#

# Create folder structure
sudo mkdir -p /opt/jira/data/{db,jira} && cd /opt/jira

Environment File
#

# Create environment file
sudo vi .env

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

JIRA_DATABASE_URL=postgresql://jira:jira@db:5432/jira
JIRA_DB_TYPE=postgres72
JIRA_DB_DRIVER=org.postgresql.Driver
JIRA_DB_USER=jira
JIRA_DB_PASSWORD=my-jira-password # Define DB PW

POSTGRES_DB=jira
POSTGRES_USER=jira
POSTGRES_PASSWORD=my-jira-password # Define DB PW

Docker Compose File
#

version: '3'

services:
  jira:
    image: "atlassian/jira-software:latest"
    container_name: jira
    env_file:
      - .env
    ports:
      - "8080:8080"
    depends_on:
      - db
    volumes:
      - ./jira:/var/atlassian/jira

  db:
    image: postgres:9.6
    container_name: jira-db
    env_file:
      - .env
    volumes:
      - ./data/db:/var/lib/postgresql/data

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 jira.jklug.work

Nginx
#

# Install nginx
sudo apt install nginx

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

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

    ssl_certificate         /etc/letsencrypt/live/jira.jklug.work/fullchain.pem;
    ssl_certificate_key     /etc/letsencrypt/live/jira.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/jira.jklug.work /etc/nginx/sites-enabled/

# Restart Nginx
sudo systemctl restart nginx