Skip to content

Traefik setup that includes https certification, redirect and watchtower for CI. The rest-api image inside the docker-compose file is build on Javalin(Java). For testing the endpoints check out the http file inside the project.)

Notifications You must be signed in to change notification settings

tysker/traefik_docker_server_setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌐 Traefik Remote Deployment Setup

A template for deploying applications on a remote server using Traefik, Docker, Docker Compose, and DigitalOcean. Provides automatic HTTPS, routing, PostgreSQL, and optional frontend hosting.


🧰 Tech Stack

Technology Purpose
Traefik Reverse proxy, HTTPS, routing
Docker Containerization
DigitalOcean Hosting
PostgreSQL Database
Nginx Optional frontend hosting


🚀 What This Template Gives You

✔ Fully functional reverse proxy ✔ Automatic SSL certificates (Let’s Encrypt) ✔ Traefik dashboard with password protection ✔ Docker-based backend + database ✔ Optional frontend deployment (React/Vue/etc.) ✔ Works on any DigitalOcean Docker Droplet ✔ Clean environment variable setup ✔ Simple debugging instructions



📌 Requirements

  • DigitalOcean account

  • Docker Droplet (from Marketplace)

  • Docker Hub account

  • A domain name

  • Domain pointing to DigitalOcean nameservers

  • Wildcard DNS record:

    *.yourdomain.com
    


🛠️ Setup Guide (Simplified)

1️⃣ Clone the repository

git clone https://github.com/tysker/traefik_setup_remote.git

(Optional cleanup: remove .git, rename folder, init new repo.)


2️⃣ Generate DigitalOcean token

Create one here: https://cloud.digitalocean.com/account/api/tokens


3️⃣ Install apache2-utils (for dashboard login)

sudo apt-get install apache2-utils

Generate hashed credentials:

echo $(htpasswd -nb <username> <password>) | sed -e s/\\$/\\$\\$/g

4️⃣ Set Traefik certificate file permissions

chmod 600 ./acme
chmod 600 ./acme/acme.json

5️⃣ Create .env

PROVIDER=digitalocean
EMAIL=<your_email>
DO_AUTH_TOKEN=<your_digitalocean_token>

TRAFIK_DOMAIN=traefik.<your_domain>
DASHBOARD_AUTH=<htpasswd_output>

API_DOMAIN=api.<your_domain>

POSTGRES_USER=<user>
POSTGRES_PASSWORD=<pw>

REPO_USER=<dockerhub_username>
REPO_PASS=<dockerhub_password>

(Plus optional API settings.)



▶️ Usage

Start:

docker-compose up -d

Stop:

docker-compose down

Traefik dashboard:

https://traefik.<your_domain>

API:

https://api.<your_domain>/api

Reset DB:

docker-compose down -v
sudo rm -rf ./data


🧪 Frontend Deployment (Optional)

(Using Nginx + multi-stage Docker build)

Add nginx.conf + Dockerfile (as provided in earlier message) to your frontend root.

Push your image to Docker Hub and update docker-compose.yml.



🗄️ Debugging Checklist

  • docker ps -a — check running containers

  • docker-compose config — verify env vars

  • docker logs <container> — inspect logs

  • Check wildcard DNS record

  • Check DigitalOcean DNS nameservers

  • chmod 600 acme.json is required

  • Run without -d to see live logs:

    docker-compose up


🖥️ ASCII Architecture Diagram

                          ┌───────────────────────────┐
                          │      Client Browser       │
                          │   https://api.domain.com  │
                          └──────────────┬────────────┘
                                         │
                                         ▼
                          ┌───────────────────────────┐
                          │         Traefik           │
                          │  - Reverse Proxy          │
                          │  - Let's Encrypt TLS      │
                          │  - Routing / Middleware   │
                          └───────┬─────────┬────────┘
                                  │         │
                                  │         │
                     ┌────────────▼─┐   ┌───▼────────────────┐
                     │   Backend     │   │   Traefik Dashboard │
                     │  (REST API)   │   │  traefik.domain.com │
                     └──────┬────────┘   └─────────┬──────────┘
                            │                      │
                            │                      │
                     ┌──────▼────────┐             │
                     │  PostgreSQL    │             │
                     │   Database     │             │
                     └───────────────┘             │
                                                   │
                                   (optional)      │
                     ┌─────────────────────────────▼─┐
                     │           Frontend             │
                     │    (React/Vue via Nginx)       │
                     │  https://app.domain.com        │
                     └────────────────────────────────┘

About

Traefik setup that includes https certification, redirect and watchtower for CI. The rest-api image inside the docker-compose file is build on Javalin(Java). For testing the endpoints check out the http file inside the project.)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published