Skip to content

treafik

late 2021 I consolidated a few servers onto one using treafik

this is one of the files I used, it keeps changing

version: "2"

services:
  traefik:
    image: traefik:v2.4
    container_name: traefik
    hostname: traefik
    restart: unless-stopped
    command:
      - --certificatesresolvers.letsencrypt.acme.dnschallenge.provider=linode
      - --certificatesresolvers.letsencrypt.acme.tlschallenge=true
      - --certificatesresolvers.letsencrypt.acme.email=addyour@gmail.com
      - --certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json
      - --entrypoints.websecure.forwardedHeaders.insecure=true
      - --entrypoints.websecure.http.tls=true
      - --entrypoints.websecure.http.tls.certResolver=letsencrypt
      - --entrypoints.websecure.http.tls.domains[0].main=mindfull.monster
      - --entrypoints.websecure.http.tls.domains[1].main=shanenull.com
      - --entrypoints.websecure.http.tls.domains[2].main=eatthe.bar
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --entrypoints.web.http.redirections.entrypoint.to=websecure
      - --entrypoints.web.http.redirections.entrypoint.scheme=https
    ports:
      - "80:80/tcp"
      - "443:443/tcp"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./certs:/letsencrypt

  sncom:
    image: "nginx"
    container_name: "sncom"
    restart: always
    volumes:
      - ./sncom:/usr/share/nginx/html
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.sncom.rule=Host(`shanenull.com`)"
      - "traefik.http.routers.sncom.entrypoints=web"
      - "traefik.http.routers.sncom.entrypoints=websecure"
      - "traefik.http.routers.sncom.tls.certresolver=letsencrypt"

  wordpress:
    depends_on:
      - db
    image: wordpress:latest 
    volumes:
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
      - ./wordpress_files:/var/www/html
      - /var/www/html/example/custom.ini:/usr/local/etc/php/conf.d/custom.ini
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: yourwordpressdbusername
      WORDPRESS_DB_PASSWORD: addyoursupersecretlongpasswordhere 
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.wordpress.rule=Host(`mindfull.monster`)"
      - "traefik.http.routers.wordpress.entrypoints=web"
      - "traefik.http.routers.wordpress.entrypoints=websecure"
      - "traefik.http.routers.wordpress.tls.certresolver=letsencrypt"

  db:
    image: mysql:5.7
    volumes:
      - ./db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: addyoursupersecretlongpasswordhere
      MYSQL_DATABASE: wordpress
      MYSQL_USER: yourwordpressdbusername
      MYSQL_PASSWORD: addyoursupersecretlongpasswordher

  eatthebar:
    image: "nginx"
    container_name: "eatthebar"
    restart: always
    volumes:
      - ./eatthebar:/usr/share/nginx/html
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.eat.rule=Host(`eatthe.bar`)"
      - "traefik.http.routers.eat.entrypoints=web"
      - "traefik.http.routers.eat.entrypoints=websecure"
      - "traefik.http.routers.eat.tls.certresolver=letsencrypt"

later I'll add more detailed instructions, you can do like I did and watch videos on youtube and read the documentation on these sites

https://gitlab.com

https://traefik.io/

https://www.linode.com/docs/guides/securing-your-server/

https://www.linode.com/docs/guides/wordpress-with-docker-compose/