我已经开始工作,但是我想做什么并且不确定如何配置它以便通过不同的前端https端口(而不是不同的子域或路径前缀)访问每个后端 .
这是Traefik的docker-compose文件和第一个服务:
version: '3.2'
services:
traefik:
image: traefik:1.6-alpine
container_name: traefik
command:
- --logLevel=INFO
- --defaultentrypoints=http,https
- --entryPoints=Name:http Address::5099 Redirect.EntryPoint:https
- --entryPoints=Name:https Address::5098 TLS:/cert/certificate.crt,/cert/private.key
- --docker
- --docker.exposedbydefault=false
- --docker.domain=example.com
ports:
- target: 5099
published: 5099
protocol: tcp
mode: host
- target: 5098
published: 5098
protocol: tcp
mode: host
volumes:
- ./cert:/cert
- /var/run/docker.sock:/var/run/docker.sock
restart: always
firefox-syncserver:
image: crazymax/firefox-syncserver:latest
container_name: traefik-firefoxsync
volumes:
- ./firefoxsync:/data
labels:
- traefik.enable=true
- traefik.backend=firefox-syncserver
- traefik.port=5000
- traefik.frontend.rule=Host:example.com
environment:
- <...config for firefoxsync...>
restart: always
有了这个,我可以通过https://example.com:5098访问服务,一切都很好 . 现在让我们尝试添加第二项服务:
traefik-manictime:
image: manictime/manictimeserver:latest
container_name: traefik-manictime
volumes:
- ./manictime:/app/Data
labels:
- traefik.enable=true
- traefik.backend=manictime
- traefik.port=8080
- traefik.frontend.rule=PathPrefix:/manictime
restart: always
这可以通过https://example.com:5098/manictime访问 . 但是,问题是服务本身无法在虚拟目录中运行(也就是说它需要位于其域的顶层 - no / manictime subdir) . 虽然我知道我可以使用子域而不是路径前缀来区分服务,但我更倾向于使用端口(其中一个原因是我需要为每个子域做一个麻烦) .
所以问题是:我可以以某种方式配置Traefik以便即
https://example.com:5098 - > https前端服务1
https://example.com:6000 - > https前端服务2
?
1 回答
您需要在新端口上创建新的TLS入口点,并将新入口点添加到默认列表(如果您希望新端口上的所有TLS服务都可用),或者使用
traefik.frontend.entryPoints
标签手动将新入口点添加到服务2 .