> ## Content Index
> Fetch the complete content index at: https://www.cxy.hk/llms.txt
> Use this file to discover other available public pages before exploring further.

# Dokploy & Traefik 反代已有 SSL 的容器
- URL: https://www.cxy.hk/dokploy-traefik-fan-dai-yi-you-ssl-de-rong-qi/
- Published: 2025-12-25T08:33:00.000Z
- Updated: 2026-10-20T11:26:09.000Z
- Author: Xinyu Chen

最近，我将我的所有服务迁移到了 Dokploy 上运行，Dokploy 使用 Traefik 将 Docker 内的服务反代到服务器的外部端口上。

 本来这个过程非常方便，只需要去图形化界面添加域名即可，但是此处 Traefik 默认是以 HTTP 协议回源，导致某些采用 HTTPS 协议的应用（比如我的 Krill，SSL 强开无法关闭）无法正常回源。

只需要加上这样一行代码即可。

```yaml
- traefik.http.services.servicename.loadbalancer.server.scheme=https

```

对于 Compose 部署方式，将这一行加到 labels 中即可，如：

```yaml
    labels:
      - traefik.http.services.rpki-infrastructure-krill*****-web.loadbalancer.server.scheme=https
      - traefik.http.services.rpki-infrastructure-krill*****-websecure.loadbalancer.server.scheme=https

```

这样即可

如果是 Application 部署的话，则需要到 Advanced > Traefik > Modify 这样修改

```diff
http:
  routers:
    rpki-infrastructure************:
      rule: Host(`rpki-infrastructure********。traefik.me`)
      service: rpki-infrastructure**********
      middlewares: []
      entryPoints:
        - web
  services:
    rpki-infrastructure***************:
      loadBalancer:
        servers:
          - url: http://rpki-infrastructure-***********:3000
+         # 加到这里
+         scheme: https
        passHostHeader: true

```

那么再进一步，如果是自签名证书呢，需要更多一步。

我们需要创建一个 serversTransports 来处理不安全状态，理论上对于 Application 来说 serversTransports 可以直接写在应用的 http 块中，Compose 也可以直接写在 labels 中但是为了方便及复用性考虑，我们将他添加到 Traefik File System 中。

点到 /etc/dokploy/traefik/dynamic/middlewares.yml ，点击 Unlock

```yaml
http:
  middlewares:
    redirect-to-https:
      redirectScheme:
        scheme: https
        permanent: true
# 添加以下内容 
  serversTransports:
    insecure:
      insecureSkipVerify: true

```

然后，我们在服务中引用该 Transport。

```yaml
      - traefik.http.services.rpki-infrastructure-krill**********.loadbalancer.serversTransport=insecure@file

```

使用 Compose 则添加这一部分，记得添加 @file，表明该 transport 来自的 Provider 是文件。

对于 Application 而言，只需要

```diff
http:
  routers:
    rpki-infrastructure************:
      rule: Host(`rpki-infrastructure********。traefik.me`)
      service: rpki-infrastructure**********
      middlewares: []
      entryPoints:
        - web
  services:
    rpki-infrastructure***************:
      loadBalancer:
        servers:
          - url: http://rpki-infrastructure-***********:3000
          scheme: https
        # 加到这里
        serversTransport: insecure
        # 这里不用加 @file 了，因为 Application 的配置文件直接就在 Traefik File System 里
        passHostHeader: true

```