我目前正在使用 Apache 作为我的 LXD 容器的代理,使用这种设置:
<VirtualHost *:80>
ServerName example.com
ProxyRequests off
ProxyPass / http://10.0.0.142/ retry=0
ProxyPassReverse / http://10.0.0.142/
ProxyPreserveHost On
</VirtualHost>
我想切换到特雷菲克。我尝试过这种配置:
defaultEntryPoints = ["http"]
[entryPoints]
[entryPoints.http]
address = ":80"
[backends]
[backends.backend1]
[backends.backend1.servers.server1]
url = "http://10.0.0.142"
[frontends]
[frontends.frontend1]
backend = "backend1"
passHostHeader = true
[frontends.frontend1.routes.example]
rule = "Host:example.com"
- 这两者等价吗?
- traefik 配置能不能简化点?(去掉不必要的规则)
(注意:我不打算使用docker,而且我也不想使用。)
答案1
您缺少后端类型定义(文件、Docker、Swarm……)。
在你的情况下,只需在你的conf文件中添加(或取消注释)[file]
,如下所示:
defaultEntryPoints = ["http"]
[entryPoints]
[entryPoints.http]
address = ":80"
[file]
[backends]
[backends.backend1]
[backends.backend1.servers.server1]
url = "http://10.0.0.142"
[frontends]
[frontends.frontend1]
backend = "backend1"
passHostHeader = true
[frontends.frontend1.routes.example]
rule = "Host:example.com"