CNAME flattening
This commit is contained in:
parent
139f280f35
commit
31a8e3e39a
16 changed files with 1724 additions and 5 deletions
16
integration/fixtures/simple_hostresolver.toml
Normal file
16
integration/fixtures/simple_hostresolver.toml
Normal file
|
@ -0,0 +1,16 @@
|
|||
logLevel = "DEBUG"
|
||||
defaultEntryPoints = ["http"]
|
||||
|
||||
[entryPoints]
|
||||
[entryPoints.http]
|
||||
address = ":8000"
|
||||
|
||||
[api]
|
||||
|
||||
[docker]
|
||||
exposedByDefault = false
|
||||
domain = "docker.local"
|
||||
watch = true
|
||||
|
||||
[hostResolver]
|
||||
cnameFlattening = true
|
54
integration/hostresolver_test.go
Normal file
54
integration/hostresolver_test.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
package integration
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/containous/traefik/integration/try"
|
||||
"github.com/go-check/check"
|
||||
checker "github.com/vdemeester/shakers"
|
||||
)
|
||||
|
||||
type HostResolverSuite struct{ BaseSuite }
|
||||
|
||||
func (s *HostResolverSuite) SetUpSuite(c *check.C) {
|
||||
s.createComposeProject(c, "hostresolver")
|
||||
|
||||
s.composeProject.Start(c)
|
||||
s.composeProject.Container(c, "server1")
|
||||
}
|
||||
|
||||
func (s *HostResolverSuite) TestSimpleConfig(c *check.C) {
|
||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/simple_hostresolver.toml"))
|
||||
defer display(c)
|
||||
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
testCase := []struct {
|
||||
desc string
|
||||
host string
|
||||
status int
|
||||
}{
|
||||
{
|
||||
desc: "host request is resolved",
|
||||
host: "www.github.com",
|
||||
status: http.StatusOK,
|
||||
},
|
||||
{
|
||||
desc: "host request is not resolved",
|
||||
host: "frontend.docker.local",
|
||||
status: http.StatusNotFound,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCase {
|
||||
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/", nil)
|
||||
c.Assert(err, checker.IsNil)
|
||||
req.Host = test.host
|
||||
|
||||
err = try.Request(req, 500*time.Millisecond, try.StatusCodeIs(test.status), try.HasBody())
|
||||
c.Assert(err, checker.IsNil)
|
||||
}
|
||||
}
|
|
@ -51,6 +51,7 @@ func init() {
|
|||
check.Suite(&FileSuite{})
|
||||
check.Suite(&GRPCSuite{})
|
||||
check.Suite(&HealthCheckSuite{})
|
||||
check.Suite(&HostResolverSuite{})
|
||||
check.Suite(&HTTPSSuite{})
|
||||
check.Suite(&LogRotationSuite{})
|
||||
check.Suite(&MarathonSuite{})
|
||||
|
|
8
integration/resources/compose/hostresolver.yml
Normal file
8
integration/resources/compose/hostresolver.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
server1:
|
||||
image: emilevauge/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.backend=backend1
|
||||
- traefik.frontend.entryPoints=http
|
||||
- traefik.frontend.rule=Host:github.com
|
Loading…
Add table
Add a link
Reference in a new issue