我正在尝试设置一组在单个ubuntu服务器上运行的容器化应用程序。我希望每个服务器都在各自的子域上运行,并使用Traefik将请求代理到基于该域的每个容器。我的SSL证书是覆盖域和所有子域的通配符证书。我的问题是,当我导航到我认为应该是正确的子域时,我无法看到这些应用程序。
这是主要Traefik容器的toml配置(从docker hub,btw中拉出):
defaultEntryPoints = ["http", "https"]
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[acme]
email = "myemail@gmail.com"
storage = "/acme.json"
entryPoint = "https"
OnHostRule = false
[[acme.domains]]
main = "*.mydomain.com"
sans = ["mydomain.com"]
[acme.dnsChallenge]
provider = "digitalocean"
delayBeforeCheck = 0
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "mydomain.com"
watch = true
exposedbydefault = false
还有Traefik容器的docker-compose.yml:
version: '3'
services:
traefik:
image: traefik:v1.7.9
#command: --docker
ports:
- "80:80"
- "443:443"
restart: always
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "./traefik.toml:/traefik.toml"
- "./acme.json:/acme.json"
environment:
- DO_AUTH_TOKEN
networks:
- default
这是我要从子域运行的一个应用程序的docker-compose.yml和Dockerfile文件之一的示例:
docker-compose.yml
version: '3'
services:
servicename:
build: .
labels:
- "traefik.enabled=true"
- "traefik.backend=servicename"
- "traefik.frontend.rule=Host:servicename.domain.com"
- "traefik.docker.network=traefik_default"
- "traefik.port=8001"
restart: always
networks:
- traefik_default
networks:
traefik_default:
external:
name: traefik_default
Dockerfile
# pull official base image
FROM ruby:2.0.0
# Copy project
COPY . .
# install dependencies
RUN bundle install
EXPOSE 8001/tcp
CMD ["bundle", "exec", "rackup", "--host", "0.0.0.0", "-p", "8001"]
这个容器化的应用程序在Traefik的基础上运行良好,但是我还无法连接它。有人知道会出什么问题吗?