带有Traefik HTTPS重定向的Docker Swarm中的Tomcat应用服务器返回网关超时

时间:2019-01-22 14:04:23

标签: docker tomcat docker-compose traefik docker-swarm-mode

我是Tomcat,Docker和traefik的新手,并且被困在试图通过Traefik https重定向在单节点docker swarm中设置Tomcat应用程序服务器。目前,我可以看到Traefik Dashoard的所有后端和前端服务都在运行,但是我的网站本身和Adminer DBAdmin页面返回“网关超时”消息,并且什么也不显示。非常感谢您的帮助。提前致谢!以下是我执行的步骤和配置:

1。 Traefik.toml

<pre>
debug = false
checkNewVersion = true
logLevel = "ERROR"
InsecureSkipVerify = true

# Access log
filePath = "/var/log/traefik/access.log"
format = "common"

#Add named EntryPoints for HTTP and HTTPS
#that all backend have access to
defaultEntryPoints = ["http", "https"]

[entryPoints]
  [entryPoints.http]
    address = ":80"
     [entryPoints.http.redirect] #2nd Force HTTPS
       entryPoint = "https"
  [entryPoints.https]
    address = ":443"
     [entryPoints.https.tls]

# Configure the api provider on port 8080
#with basic authentication method
  [entryPoints.dashboard]
    address = ":8080"
     [entryPoints.dashboard.auth]
       [entryPoints.dashboard.auth.basic]
         users = ["myuser:$apr1$EbvR0Rs3cr8PRzQGp8a3Wt5apSROCP61"]

  [api]
  entrypoint="dashboard"

#Enable retry if network error
  [retry]

#Letsencrypt configuration with ACME HTTP challenge
  [acme]
  email = "mail@example.com"
  storage = "acme.json"
  entryPoint = "https"
  onHostRule = true
   [acme.httpChallenge]
   entryPoint = "http"
   [[acme.domains]]
    main = "EXAMPLE.COM"
  [[acme.domains]]
    main = "MONITOR.EXAMPLE.COM"
  [[acme.domains]]
    main = "DBADMIN.EXAMPLE.COM"

#Define Docker Backend Configuration
  [docker]
  domain = "example.com"
  network = "web"
  watch = true
<code>

2。创建网桥,acme.json文件(和chmod 600),然后使用以下命令创建traefik容器:

<pre>
docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $PWD/traefik.toml:/traefik.toml \
-v $PWD/acme.json:/acme.json \
-v traefikdata:/traefik \
-p 80:80 \
-p 443:443 \
-l traefik.enable=true \
-l traefik.frontend.rule=Host:monitor.example.com \
-l traefik.port=8080 \
--restart=always \
--network web \
--name traefik \
traefik:1.7.6-alpine
<code>

3。设置一群

<pre>
docker swarm init
<code>

4。创建可附加的覆盖网络

<pre>
docker network create --driver overlay --attachable <network-name>
<code>

5。将Traefik容器连接到覆盖网络

<pre>
docker network connect <network-name> <container-name>
<code>
  1. 使用docker-compose.yml文件向Traefik注册容器

    version: "3.6"

    networks: frontend: driver: overlay backend:

    services: myapp: image: app/app deploy: replicas: 3 restart_policy: condition: on-failure volumes: - "./sitedata:/path-to/htdoc/_data" environment: DB_NAME: "mydb" DB_USER: "dbuser" DB_PASSWORD: "secret" labels: - "traefik.enable=true" - traefik.backend=myapp - traefik.frontend.rule=Host:myapp.example.com - traefik.docker.network=frontend - traefik.port=80 networks: - backend - frontend depends_on: - mydb

    mydb: image: myapp/db deploy: replicas: 3 restart_policy: condition: on-failure volumes: - "./pgdata:/path-to/data/mydata" environment: POSTGRES_DB: 'mydb' POSTGRES_USER: 'dbuser' POSTGRES_PASSWORD: 'secret' PGDATA: /path-to/data/mydata networks: - backend labels: - traefik.enable=false # to specify that Traefik should not expose

    adminer: image: adminer:4.7-standalone deploy: replicas: 1 restart_policy: condition: on-failure volumes: - "./path-to/data/data" labels: - "traefik.enable=true" - traefik.backend=adminer - traefik.frontend.rule=Host:dbadmin.example.com - traefik.docker.network=frontend - traefik.port=8080 networks: - backend - frontend depends_on: - mydb

7. Run the containers

<pre> docker stack deploy -c docker-compose.yml myawesomeapp <code>

结果 ==========

此刻我只能看到我的Traefik仪表板

Traefik Dashboad

我的网站和dbadmin页面都返回“网关超时”消息

Gateway Timeout error from website, as well as, dbadmin page

0 个答案:

没有答案