gpt4 book ai didi

reverse-proxy - Traefik v2 作为没有 docker 的反向代理

转载 作者:行者123 更新时间:2023-12-04 03:52:08 25 4
gpt4 key购买 nike

我已经阅读了文档,但我无法弄清楚如何配置 Traefik v2 以在不涉及 Docker 的情况下将 Nginx 替换为网站(虚拟主机)的反向代理。理想情况下,我们也会加密 https。

我在 http://127.0.0.1:4000 上运行了一项服务我想从 http://myhost.com:80 反向代理到

这是我到目前为止提出的配置:

[Global]
checkNewVersion = true

[log]
level = "DEBUG"
filePath = "log-file.log"

[accessLog]
filePath = "log-access.log"
bufferingSize = 100

[entrypoints]
[entrypoints.http]
address = ":80"

[http]
[http.routers]
[http.routers.my-router]
rule = "Host(`www.myhost.com`)"
service = "http"
entrypoint=["http"]

[http.services]
[http.services.http.loadbalancer]
[[http.services.http.loadbalancer.servers]]
url = "http://127.0.0.1:4000"

最佳答案

我想到了,
首先要注意的是,在 traefik v2 中有两种类型的配置,静态和动态。所以我创建了两个文件,traefik.toml 和 traefik-dynamic.toml。

traefik.toml 的内容:

[log]
level = "DEBUG"
filePath = "log-file.log"

[accessLog]
filePath = "log-access.log"
bufferingSize = 100

[providers]
[providers.file]
filename = "traefik-dynamic.toml"

[api]
dashboard = true
debug = true

[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.web-secure]
address = ":443"
[entryPoints.dashboard]
address = ":8080"

[certificatesResolvers.sample.acme]
email = "myemail@example.com"
storage = "acme.json"

[certificatesResolvers.sample.acme.httpChallenge]
# used during the challenge
entryPoint = "web"


traefik-dynamic.toml:

[http]
# Redirect to https
[http.middlewares]
[http.middlewares.test-redirectscheme.redirectScheme]
scheme = "https"

[http.routers]
[http.routers.my-router]
rule = "Host(`www.example.com`)"
service = "phx"
entryPoints = ["web-secure"]
[http.routers.my-router.tls]
certResolver = "sample"

[http.services]
[http.services.phx.loadbalancer]
[[http.services.phx.loadbalancer.servers]]
url = "http://127.0.0.1:4000"

关于reverse-proxy - Traefik v2 作为没有 docker 的反向代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58496270/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com