Answer the question
In order to leave comments, you need to log in
Traefik + Docker SSL setup?
Hello everyone, please tell me how to properly configure an SSL certificate in a docker container, there are 2 projects with their
PHP
Mysql
Nginx containers,
here is the docker-compose.yml of the project:
# Версия docker-compose
version: '3'
# Список наших сервисов (контейнеров)
services:
composer:
build: ./docker/composer/
nginx:
# используем последний стабильный образ nginx
build: ./docker/nginx/
networks:
- web
# nginx должен общаться с php контейнером
links:
- php
# монтируем директорию с проектом
volumes:
- ./project:/var/www/crm
- ./docker/nginx/conf:/etc/nginx/conf.d
- ./docker/nginx/logs/error.log:/var/log/nginx/error.log
- ./docker/nginx/logs/access.log:/var/log/nginx/access.log
labels:
- traefik.enable=true
- traefik.port=443
- traefik.http.routers.site_nginx.rule=Host(`example.com`)
- traefik.http.routers.site_nginx.entrypoints=http
- traefik.http.routers.site_nginxs.rule=Host(`example.com`)
- traefik.http.routers.site_nginxs.entrypoints=https
- traefik.http.routers.site_nginxs.tls=true
- traefik.http.routers.site_nginxs.tls.certresolver=sample
- traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
- traefik.http.routers.site_nginx.middlewares=redirect-to-https
php:
# у нас свой образ для PHP, указываем путь к нему и говорим что его надо собрать
build: ./docker/php/
# этот образ будет общаться с mysql, composer
links:
- mysql
- composer
networks:
- web
# монтируем директорию с проектом
volumes:
- ./project:/var/www/crm
- ./docker/php/php.ini:/usr/local/etc/php/conf.d/40-custom.ini
mysql:
image: mysql
environment:
MYSQL_DATABASE: "${DB_NAME}"
MYSQL_ROOT_PASSWORD: "${DB_PASS}"
networks:
- web
networks:
web:
external: true
version: '3.3'
services:
traefik:
image: traefik:latest
container_name: traefik
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik.yml:/traefik.yml
- ./acme.json:/acme.json
labels:
- traefik.enable=true
- traefik.http.routers.traefik.rule=Host(`traefik.example.com`)
- [email protected]
- traefik.http.routers.traefik.middlewares=auth
- traefik.http.routers.traefik.tls.certresolver=sample
- traefik.http.middlewares.auth.basicauth.users=user:pass
networks:
- web
networks:
web:
external: true
log:
level: DEBUG
api:
dashboard: true
providers:
docker:
exposedbydefault: false
endpoint: unix:///var/run/docker.sock
network: web
entrypoints:
http:
address: :80
https:
address: :443
certificatesResolvers:
sample:
acme:
tlschallenge: {}
email: [email protected]
storage: acme.json
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question