http: routers: main-https: rule: &host_rule "Host(`example.com`) || Host(`www.example.com`)" entryPoints: - websecure service: main-service # 如果需要使用自动申请SSL证书,自动续期等功能,请取消注释以下内容 # tls: # certResolver: myresolver main-http-redirect: rule: *host_rule entryPoints: - web middlewares: - redirect-to-https service: noop services: main-service: loadBalancer: servers: - url: "http://100.100.100.100:3000" # 这里填写你的后端服务地址(上游服务) noop: loadBalancer: servers: - url: "http://127.0.0.1:65535" # 占位用,无实际后端,仅用于HTTP跳转 middlewares: redirect-to-https: redirectScheme: scheme: https permanent: true