Traefik Docker Compose Example:
version: '3.7'
networks:
livedignet:
external: true
services:
traefik:
image: "traefik:2.1"
container_name: "traefik"
networks:
- livedignet
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.ldhttpchallenge.acme.httpchallenge=true"
- "--certificatesresolvers.ldhttpchallenge.acme.httpchallenge.entrypoint=web"
When u are on test stage. UnComment the line below.
- "--certificatesresolvers.ldhttpchallenge.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
- "--certificatesresolvers.ldhttpchallenge.acme.email=your@email.com"
- "--certificatesresolvers.ldhttpchallenge.acme.storage=/letsencrypt/acme.json" ports:
- "80:80/tcp"
- "443:443/tcp"
- "8080:8080/tcp" volumes:
- type: bind source: "./letsencrypt" target: "/letsencrypt"
- type: bind source: "/var/run/docker.sock" target: "/var/run/docker.sock"
Web Application Example:
version: '3.7'
networks:
livedignet:
external: true
services:
livedig:
image: 'wordpress:latest'
container_name: "livedig"
networks:
-
livedignet external_links:
-
mysql environment: WORDPRESS_DB_HOST: 'mysql:3306' WORDPRESS_DB_USER: 'mysql_usrname' WORDPRESS_DB_PASSWORD: 'mysql_password' WORDPRESS_DB_NAME: 'mysql_dbname' WORDPRESS_TABLEPREFIX: 'wp' working_dir: '/var/www/html' labels:
-
"traefik.enable=true"
-
"traefik.http.routers.livedig_http.rule=Host(
livedig.com
)" -
"traefik.http.routers.livedig_http.entrypoints=web"
-
"traefik.http.routers.livedig_http.middlewares=redirect-to-https"
-
"traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
-
"traefik.http.routers.livedig.rule=Host(
livedig.com
)" -
"traefik.http.routers.livedig.entrypoints=websecure"
-
"traefik.http.routers.livedig.tls.certresolver=ldhttpchallenge" ports:
-
'80' volumes:
-
type: bind source: ./wp-content target: /var/www/html/wp-content read_only: false
发表回复