首页 > 解决方案 > 使用 Traefik 的简单 http 反向代理总是产生 404

问题描述

我使用以下命令使用预构建的二进制文件(v1.6.4)启动了 Traefik:

./traefik_linux-amd64 --configFile=traefik.toml

traefik.toml 文件:

defaultEntryPoints = ["http"]

[entryPoints]
  [entryPoints.http]
    address = ":11111"

[backends]
  [backends.abcd]
    [backends.abcd.servers]
      [backends.abcd.servers.server0]
        url = "http://10.0.3.192:80"

[frontends]
  [frontends.frontend1]
    backend = "abcd"
    [frontends.frontend1.routes.abcd]
      rule = "Path:/abcd"

卷曲http://localhost:11111/abcd -v

*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 11111 (#0)
> GET /abcd HTTP/1.1
> Host: localhost:11111
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
< Date: Mon, 25 Jun 2018 02:00:27 GMT
< Content-Length: 19
< 
404 page not found
* Connection #0 to host localhost left intact

服务在http://10.0.3.192:80(在 lxc 容器内)运行,如果我直接 curl: curl http://10.0.3.192 -v

* Rebuilt URL to: http://10.0.3.192/
*   Trying 10.0.3.192...
* Connected to 10.0.3.192 (10.0.3.192) port 80 (#0)
> GET / HTTP/1.1
> Host: 10.0.3.192
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Mon, 25 Jun 2018 01:58:12 GMT
< Content-Length: 34
< Content-Type: text/plain; charset=utf-8
< 
* Connection #0 to host 10.0.3.192 left intact
<snip / garbage out>

我应该对配置文件做些什么不同的事情?

编辑:解决。看评论。

标签: traefik

解决方案


推荐阅读