首页 文章

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

提问于
浏览
0

我有一个专用服务器,我安装了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文件中 . .

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

谢谢!

1 回答

  • 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)

    BUT 由于某种原因,我仍然可以从htttp://12.34.56.78:8080访问Rancher服务器(注意,这不是https)虽然物理服务器已防火墙 all 端口(ufw在Ubuntu上),除了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配置泄漏...... :(

相关问题