Skip to content

Instantly share code, notes, and snippets.

@ohnotnow
Created December 5, 2019 14:09
Show Gist options
  • Save ohnotnow/1b5df2c8bba008bc7a92d5d63a3047a1 to your computer and use it in GitHub Desktop.
Save ohnotnow/1b5df2c8bba008bc7a92d5d63a3047a1 to your computer and use it in GitHub Desktop.
test wordpress traefik 2 stack
version: "3.3"
services:
wordpress: # <== we aren't going to open :80 here because traefik is going to serve this on entrypoint 'web'
## :80 is already exposed from within the container ##
image: wordpress
restart: always
container_name: wp
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- wordpress:/var/www/html
networks:
- proxy
- backend
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.nginx-web.rule=Host(`your.site.com`)"
- "traefik.http.routers.nginx-web.entrypoints=web"
- "traefik.http.services.nginx-web.loadbalancer.server.port=80"
# - "traefik.http.routers.nginx-web.service=nginx-web"
# - "traefik.http.services.nginx-web.loadbalancer.server.scheme=http"
# - "traefik.http.routers.nginx-web.middlewares=redirect@file" # <== This is a middleware to redirect to https
# - "traefik.http.routers.nginx-secured.rule=Host(`example.com`)" # <== Your Domain Name for the https rule
# - "traefik.http.routers.nginx-secured.entrypoints=web-secured" # <== Defining entrypoint for https, **ref: line 31
# - "traefik.http.routers.nginx-secured.tls.certresolver=mytlschallenge" # <== Defining certsresolvers for https
###############################################
### DB Container not on traefik #####
#############################################
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- db:/var/lib/mysql
networks:
- backend
networks:
backend:
proxy:
external: true
volumes:
db:
wordpress:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment