我正在尝试使用traefik,grafana,zabbix,gotify等制作监视堆栈。 我有一个名为 domain.tld 的域名。
在docker-compose中,我有一些具有不同端口的服务(例如grafana),但是我也有一些服务位于同一端口(gotify,zabbix)。
我想使用zabbix.domain.tld,grafana.domain.tld将我的domain.tld重定向到每个使用SSL的容器。 可以,但是不完全可以。
如果我在地址栏中输入: grafana.domain.tld -> 404 SSL重定向错误
如果我在地址栏中输入: grafana.domain.tld:3000 ->可以
我认为,在我进行的许多修改中,我几乎没有丢失(或完全丢失?)。 单单我和医生还不够。
所以,我的docker-compose:
version: '3.5'
networks:
traefik_front:
external: true
services:
traefik:
image: traefik
command: --api --docker
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- "${TRAEFIK_PATH}/traefik.toml:/etc/traefik/traefik.toml"
- "${TRAEFIK_PATH}/acme.json:/acme.json"
- /var/run/docker.sock:/var/run/docker.sock
labels:
- "traefik.frontend.rule=Host:traefik.${DOMAIN}"
- "treafik.port=8080"
- "traefik.enable=true"
- "traefik.backend=traefik"
- "traefik.docker.network=traefik_front"
#- "traefik.frontend.entryPoints=http,https"
networks:
- traefik_front
gotify:
image: gotify/server
container_name: gotify
volumes:
- "${GOTIFY_PATH}:/app/data"
env_file:
- env/.env_gotify
labels:
- "traefik.frontend.rule=Host:push.${DOMAIN}"
- "traefik.port=80"
- "traefik.enable=true"
- "traefik.backend=gotify"
- "traefik.docker.network=traefik_front"
networks:
- traefik_front
- default
grafana:
image: grafana/grafana
container_name: grafana
volumes:
- "${GF_PATH}:/var/lib/grafana"
env_file:
- env/.env_grafana
labels:
- "traefik.frontend.rule=Host:grafana.${DOMAIN}"
- "traefik.port=3000"
- "traefik.enable=true"
- "traefik.backend=grafana"
- "traefik.docker.network=traefik_front"
networks:
- traefik_front
- default
zabbix-server:
image: zabbix/zabbix-server-mysql:ubuntu-4.0-latest
volumes:
- "${ZABBIX_PATH}/alertscripts:/usr/lib/zabbix/alertscripts:ro"
- "${ZABBIX_PATH}/externalscripts:/usr/lib/zabbix/externalscripts:ro"
- "${ZABBIX_PATH}/modules:/var/lib/zabbix/modules:ro"
- "${ZABBIX_PATH}/enc:/var/lib/zabbix/enc:ro"
- "${ZABBIX_PATH}/ssh_keys:/var/lib/zabbix/ssh_keys:ro"
- "${ZABBIX_PATH}/mibs:/var/lib/zabbix/mibs:ro"
- "${ZABBIX_PATH}/snmptraps:/var/lib/zabbix/snmptraps:ro"
links:
- mysql-server:mysql-server
env_file:
- env/.env_zabbix_db_mysql
- env/.env_zabbix_srv
user: root
depends_on:
- mysql-server
- zabbix-snmptraps
labels:
- "traefik.backend=zabbix-server"
- "traefik.port=10051"
zabbix-web-apache-mysql:
image: zabbix/zabbix-web-apache-mysql:ubuntu-4.0-latest
links:
- mysql-server:mysql-server
- zabbix-server:zabbix-server
volumes:
- "${ZABBIX_PATH}/ssl/apache2:/etc/ssl/apache2:ro"
env_file:
- env/.env_zabbix_db_mysql
- env/.env_zabbix_web
user: root
depends_on:
- mysql-server
- zabbix-server
labels:
- "traefik.frontend.rule=Host:zabbix.${DOMAIN}"
- "traefik.port=80"
- "traefik.enable=true"
- "traefik.backend=zabbix-web"
- "traefik.docker.network=traefik_front"
networks:
- traefik_front
- default
zabbix-agent:
image: zabbix/zabbix-agent:ubuntu-4.0-latest
ports:
- "10050:10050"
volumes:
- "${ZABBIX_PATH}/zabbix_agentd.d:/etc/zabbix/zabbix_agentd.d:ro"
- "${ZABBIX_PATH}/modules:/var/lib/zabbix/modules:ro"
- "${ZABBIX_PATH}/enc:/var/lib/zabbix/enc:ro"
- "${ZABBIX_PATH}/ssh_keys:/var/lib/zabbix/ssh_keys:ro"
links:
- zabbix-server:zabbix-server
env_file:
- env/.env_zabbix_agent
user: root
networks:
- default
zabbix-snmptraps:
image: zabbix/zabbix-snmptraps:ubuntu-4.0-latest
ports:
- "162:162/udp"
volumes:
- "${ZABBIX_PATH}/snmptraps:/var/lib/zabbix/snmptraps:rw"
user: root
networks:
- default
mysql-server:
image: mysql:5.7
command: [mysqld, --character-set-server=utf8, --collation-server=utf8_bin]
volumes:
- /var/lib/mysql:/var/lib/mysql:rw
env_file:
- env/.env_zabbix_db_mysql
labels:
- "traefik.enable=false"
user: root
networks:
- default
还有我的traefik.toml:
# WEBUI
[web]
entryPoint = "dashboard"
dashboard = true
address = ":8080"
usersFile = "/etc/docker/traefik/.htpasswd"
logLevel = "ERROR"
# Force HTTPS
defaultEntryPoints = ["http", "https"]
[entryPoints]
[entryPoints.dashboard]
address = ":8080"
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[docker]
endpoint = "unix:///var/run/docker.sock"
watch = true
exposedbydefault = false
domain = "domain.tld"
network = "traefik_front"
# Let's Encrypt
[acme]
email = "mail@mail.fr"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
onDemand = false
[acme.httpChallenge]
entryPoint = "http"
OnHostRule = true
[[acme.domains]]
main = "domain.tld"
[[acme.domains]]
main = "domain.tld"
[[acme.domains]]
main = "domain.tld"
[[acme.domains]]
main = "domain.tld"
答案 0 :(得分:0)
我做过类似的事情,它将在您的设置中显示出来
docker-compose.yml
service:
traefik:
labels:
- "treafik.port=8080"
- "traefik.enable=true"
- "traefik.backend=traefik"
- "traefik.docker.network=traefik_front"
- "traefik.frontend.rule=Host:traefik.${DOMAIN}"
- "traefik.webservice.frontend.entryPoints=https"
zabbix-web-apache-mysql:
labels:
- "traefik.port=80"
- "traefik.enable=true"
- "traefik.backend=zabbix-web"
- "traefik.passHostHeader=true"
- "traefik.docker.network=traefik_front"
- "traefik.frontend.rule=Host:zabbix.${DOMAIN}"
grafana:
labels:
- "traefik.port=3000"
- "traefik.enable=true"
- "traefik.backend=grafana"
- "traefik.passHostHeader=true"
- "traefik.docker.network=traefik_front"
- "traefik.frontend.rule=Host:grafana.${DOMAIN}"
以及我的traefik.toml的配置方式
InsecureSkipVerify = true ## This is optional
## Force HTTPS
[entryPoints]
[entryPoints.http]
passHostHeader = true
address = ":80"
[entryPoints.http.forwardedHeaders]
insecure = true
[entryPoints.http.proxyProtocol]
insecure = true
## This seems to be an absolute requirement for redirect
## ...but it redirects every request to https
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.traefik]
address = ":8080"
[entryPoints.traefik.auth.basic]
# the "user" password is the MD5 encrpytion of the word "pass"
users = ["user:$apr1$.LWU4fEi$4YipxeuXs5T0xulH3S7Kb."]
[entryPoints.https]
passHostHeader = true
address = ":443"
[entryPoints.https.tls] ## This seems to be an absolute requirement
[entryPoints.https.forwardedHeaders]
insecure = true
[entryPoints.https.proxyProtocol]
insecure = true