【发布时间】:2022-07-12 17:17:08
【问题描述】:
从昨天开始,我开始使用 traefik,并尝试使用当前设置解决以下问题:
- 安装 docker 访问 Ubuntu 服务器
- traefik.example.com 和 pgadmin.example.com 的自签名证书
- 使用有效的 SSL 从我的机器解析 URL,例如:https://pgadmin.example.com
以下设置失败,因为它无法解析并且无法访问服务: docker-compose.yml
services:
traefik:
container_name: traefik
image: traefik:latest
restart: always
ports:
- 80:80
- 443:443
- 8080:8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./config/traefik.yml:/etc/traefik/traefik.yml:ro
- ./config/dynamic:/etc/traefik/dynamic:ro
- ./certs:/etc/traefik/certs:ro
labels:
- "com.centurylinklabs.watchtower.enable=true"
networks:
- dev
networks:
dev:
external:
name: dev
traefik.yml
global:
checkNewVersion: true
sendAnonymousUsage: false
log:
level: DEBUG
entryPoints:
web:
address: :80
http:
redirections:
entryPoint:
to: websecure
scheme: https
permanent: true
websecure:
address: :443
http:
tls: true
api:
insecure: true
providers:
docker:
exposedByDefault: false
file:
directory: /etc/traefik/dynamic
watch: true
dynamic_conf.yml
# Dynamic configuration
# SSL Certs
tls:
certificates:
- certFile: /etc/traefik/certs/traefik.example.com.cert.pem
keyFile: /etc/traefik/certs/traefik.example.com.key.pem
用于 postgres 和 pgadmin 的 docker-compose.yml
services:
postgres:
container_name: postgres
image: postgres
restart: always
ports:
- '5434:5432'
volumes:
- pg-dataset:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: test1234
networks:
- dev
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
restart: always
depends_on:
- postgres
ports:
- '53603:53603'
- '8081:80'
volumes:
- pgadmin-data:/var/lib/pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: admin@example.com
PGADMIN_DEFAULT_PASSWORD: root
labels:
- traefik.http.middlewares.pgadmin_https.redirectscheme.scheme=https
- traefik.http.routers.pgadmin.entrypoints=web
- traefik.http.routers.pgadmin.rule=Host(`pgadmin.example.com`)
- traefik.http.routers.pgadmin_https.rule=Host(`pgadmin.example.com`)
- traefik.http.routers.pgadmin.middlewares=pgadmin_https@docker
- traefik.http.routers.pgadmin_https.tls=true
- traefik.http.routers.pgadmin_https.entrypoints=websecure
networks:
- dev
volumes:
pg-dataset:
pgadmin-data:
networks:
dev:
external:
name: dev
在此设置中我应该在哪里存储例如 pgadmin 的证书?
过去我习惯使用 nginx,因此我现在对 traefik 有点困惑。
感谢您的帮助,我真的很感激。
【问题讨论】:
-
你检查了吗 - pgadmin.org/docs/pgadmin4/6.2/…
-
是的,当然。但是 traefik 已经分配了 443 端口,因此它应该处理 SSL。
标签: docker docker-compose openssl traefik pgadmin