我可以通过托管的Traefik容器为Rancher Server提供服务吗?

时间:2017-12-08 23:25:06

标签: docker rancher traefik

我有一个专用服务器,我安装了Rancher服务器和Rancher客户端,用于托管一些dockerized服务。

我已经成功安装了Traefik,它配置了Rancher API后端,它反向代理我的服务,在HTTPS后面托管它们,一切正常。

但我仍然通过htttp://12.34.56.78:8080访问我的Rancher服务器。我也想把Rancher服务器放在Traefik后面,也启用了https。

我尝试使用以下命令启动Rancher服务器:

sudo docker run -d \
  -v /data/rancher/server/data:/var/lib/mysql \
  --restart=unless-stopped \
  -p 8080:8080 \
  -l traefik.frontend.rule=Host:rancher.mydomainname.com \
  -l traefik.enable=true \
  -l traefik.backend=rancher \
  -l traefik.default.protocol=http \
  -l traefik.port=8080 \
  rancher/server:v1.6.12

(与我配置所有其他服务的方式相同)但Traefik没有选择它,因为(我认为)Rancher Server没有出现在Traefik正在监控的Rancher API请求中(因为Rancher服务器是在Rancher外部启动的)而不是由它主持。)

来自Rancher Active Proxy,这是该工具的it was supported

如果我的推理是正确的,Traefik无法以这种方式“接收”Rancher服务器,我想的另一种解决方案是,我可能只需为Rancher服务器创建一个单独的[file]部分,将它添加到Traefik .toml文件......

这是实现我想要的正确方法,还是有更好的方法来做到这一点......?

谢谢!

2 个答案:

答案 0 :(得分:0)

部分回答我的问题......

创建单独的静态rancherserver.toml文件:

[backends]
[backends.rancherserver]
    [backends.rancherserver.servers.server1]
    url = "http://12.34.56.78:8080"
    weight = 10

[frontends]
[frontends.rancherserver]
backend = "rancherserver"
passHostHeader = true
entrypoints = ["https"] 
    [frontends.rancherserver.routes.onlyone]
    rule = "Host:rancher.mydomain.com"

(其中12.34.56.78是物理服务器的真实物理IP地址)似乎解决了我的问题,能够通过htttps://rancher.mydomain.com访问Rancher服务器(自动从http转发到https)< / p>

但是由于某种原因,我仍然能够从htttp://12.34.56.78:8080访问Rancher服务器(注意,这不是https),尽管物理服务器已经防火墙< strong>所有端口(Ubuntu上的ufw),除了80和433(以及其他一些):

me@server:~$ sudo ufw status verbose
[sudo] password for me: 
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), deny (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
22                         ALLOW IN    Anywhere                  
443                        ALLOW IN    Anywhere                  
80                         ALLOW IN    Anywhere                  
1143                       ALLOW IN    Anywhere                  
1110                       ALLOW IN    Anywhere                  
Anywhere on docker0        ALLOW IN    Anywhere                  
22 (v6)                    DENY IN     Anywhere (v6)             
443 (v6)                   ALLOW IN    Anywhere (v6)             
80 (v6)                    ALLOW IN    Anywhere (v6)             
1143 (v6)                  ALLOW IN    Anywhere (v6)             
1110 (v6)                  ALLOW IN    Anywhere (v6)             
Anywhere (v6) on docker0   ALLOW IN    Anywhere (v6)             

所以,我仍然认为我正在滥用Traefik,并允许8080端口通过我的Traefik配置泄漏...... :(

答案 1 :(得分:0)

我晚了将近2年,但是我刚从rancher开始,traefik的后端是[docker]

用于rancher的docker-compose文件:

version: '3'

services:

  web:
   image: rancher/rancher:latest
   labels:
     traefik.enable: true
     traefik.backend: rancher
     traefik.frontend.entryPoints: http,https
     traefik.frontend.passHostHeader: true
     traefik.frontend.rule: "Host:rancher.mydomain.com"
     traefik.backend.port: 80
     traefik.port: 80
   restart: unless-stopped

也许这对绊倒这个问题的人很有用。