Adds Docker provider support
Co-authored-by: Julien Salleyron <julien@containo.us>
This commit is contained in:
parent
8735263930
commit
b54c956c5e
78 changed files with 3476 additions and 5587 deletions
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
"github.com/containous/traefik/integration/try"
|
||||
"github.com/containous/traefik/log"
|
||||
"github.com/containous/traefik/old/middlewares/accesslog"
|
||||
"github.com/containous/traefik/middlewares/accesslog"
|
||||
"github.com/go-check/check"
|
||||
checker "github.com/vdemeester/shakers"
|
||||
)
|
||||
|
@ -27,11 +27,11 @@ const (
|
|||
type AccessLogSuite struct{ BaseSuite }
|
||||
|
||||
type accessLogValue struct {
|
||||
formatOnly bool
|
||||
code string
|
||||
user string
|
||||
frontendName string
|
||||
backendURL string
|
||||
formatOnly bool
|
||||
code string
|
||||
user string
|
||||
routerName string
|
||||
serviceURL string
|
||||
}
|
||||
|
||||
func (s *AccessLogSuite) SetUpSuite(c *check.C) {
|
||||
|
@ -56,6 +56,12 @@ func (s *AccessLogSuite) TestAccessLog(c *check.C) {
|
|||
cmd, display := s.traefikCmd(withConfigFile("fixtures/access_log_config.toml"))
|
||||
defer display(c)
|
||||
|
||||
defer func() {
|
||||
traefikLog, err := ioutil.ReadFile(traefikTestLogFile)
|
||||
c.Assert(err, checker.IsNil)
|
||||
log.Info(string(traefikLog))
|
||||
}()
|
||||
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
@ -98,11 +104,11 @@ func (s *AccessLogSuite) TestAccessLogAuthFrontend(c *check.C) {
|
|||
|
||||
expected := []accessLogValue{
|
||||
{
|
||||
formatOnly: false,
|
||||
code: "401",
|
||||
user: "-",
|
||||
frontendName: "Auth for frontend-Host-frontend-auth-docker-local",
|
||||
backendURL: "/",
|
||||
formatOnly: false,
|
||||
code: "401",
|
||||
user: "-",
|
||||
routerName: "rt-authFrontend",
|
||||
serviceURL: "-",
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -140,16 +146,23 @@ func (s *AccessLogSuite) TestAccessLogAuthFrontend(c *check.C) {
|
|||
checkNoOtherTraefikProblems(c)
|
||||
}
|
||||
|
||||
func (s *AccessLogSuite) TestAccessLogAuthEntrypoint(c *check.C) {
|
||||
func (s *AccessLogSuite) TestAccessLogDigestAuthMiddleware(c *check.C) {
|
||||
ensureWorkingDirectoryIsClean()
|
||||
|
||||
expected := []accessLogValue{
|
||||
{
|
||||
formatOnly: false,
|
||||
code: "401",
|
||||
user: "-",
|
||||
frontendName: "Auth for entrypoint",
|
||||
backendURL: "/",
|
||||
formatOnly: false,
|
||||
code: "401",
|
||||
user: "-",
|
||||
routerName: "rt-digestAuthMiddleware",
|
||||
serviceURL: "-",
|
||||
},
|
||||
{
|
||||
formatOnly: false,
|
||||
code: "200",
|
||||
user: "test",
|
||||
routerName: "rt-digestAuthMiddleware",
|
||||
serviceURL: "http://172.17.0",
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -163,111 +176,9 @@ func (s *AccessLogSuite) TestAccessLogAuthEntrypoint(c *check.C) {
|
|||
|
||||
checkStatsForLogFile(c)
|
||||
|
||||
s.composeProject.Container(c, "authEntrypoint")
|
||||
s.composeProject.Container(c, "digestAuthMiddleware")
|
||||
|
||||
waitForTraefik(c, "authEntrypoint")
|
||||
|
||||
// Verify Traefik started OK
|
||||
checkTraefikStarted(c)
|
||||
|
||||
// Test auth entrypoint
|
||||
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8004/", nil)
|
||||
c.Assert(err, checker.IsNil)
|
||||
req.Host = "entrypoint.auth.docker.local"
|
||||
|
||||
err = try.Request(req, 500*time.Millisecond, try.StatusCodeIs(http.StatusUnauthorized), try.HasBody())
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
// Verify access.log output as expected
|
||||
count := checkAccessLogExactValuesOutput(c, expected)
|
||||
|
||||
c.Assert(count, checker.GreaterOrEqualThan, len(expected))
|
||||
|
||||
// Verify no other Traefik problems
|
||||
checkNoOtherTraefikProblems(c)
|
||||
}
|
||||
|
||||
func (s *AccessLogSuite) TestAccessLogAuthEntrypointSuccess(c *check.C) {
|
||||
ensureWorkingDirectoryIsClean()
|
||||
|
||||
expected := []accessLogValue{
|
||||
{
|
||||
formatOnly: false,
|
||||
code: "200",
|
||||
user: "test",
|
||||
frontendName: "Host-entrypoint-auth-docker",
|
||||
backendURL: "http://172.17.0",
|
||||
},
|
||||
}
|
||||
|
||||
// Start Traefik
|
||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/access_log_config.toml"))
|
||||
defer display(c)
|
||||
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
checkStatsForLogFile(c)
|
||||
|
||||
s.composeProject.Container(c, "authEntrypoint")
|
||||
|
||||
waitForTraefik(c, "authEntrypoint")
|
||||
|
||||
// Verify Traefik started OK
|
||||
checkTraefikStarted(c)
|
||||
|
||||
// Test auth entrypoint
|
||||
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8004/", nil)
|
||||
c.Assert(err, checker.IsNil)
|
||||
req.Host = "entrypoint.auth.docker.local"
|
||||
req.SetBasicAuth("test", "test")
|
||||
|
||||
err = try.Request(req, 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.HasBody())
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
// Verify access.log output as expected
|
||||
count := checkAccessLogExactValuesOutput(c, expected)
|
||||
|
||||
c.Assert(count, checker.GreaterOrEqualThan, len(expected))
|
||||
|
||||
// Verify no other Traefik problems
|
||||
checkNoOtherTraefikProblems(c)
|
||||
}
|
||||
|
||||
func (s *AccessLogSuite) TestAccessLogDigestAuthEntrypoint(c *check.C) {
|
||||
ensureWorkingDirectoryIsClean()
|
||||
|
||||
expected := []accessLogValue{
|
||||
{
|
||||
formatOnly: false,
|
||||
code: "401",
|
||||
user: "-",
|
||||
frontendName: "Auth for entrypoint",
|
||||
backendURL: "/",
|
||||
},
|
||||
{
|
||||
formatOnly: false,
|
||||
code: "200",
|
||||
user: "test",
|
||||
frontendName: "Host-entrypoint-digest-auth-docker",
|
||||
backendURL: "http://172.17.0",
|
||||
},
|
||||
}
|
||||
|
||||
// Start Traefik
|
||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/access_log_config.toml"))
|
||||
defer display(c)
|
||||
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
checkStatsForLogFile(c)
|
||||
|
||||
s.composeProject.Container(c, "digestAuthEntrypoint")
|
||||
|
||||
waitForTraefik(c, "digestAuthEntrypoint")
|
||||
waitForTraefik(c, "digestAuthMiddleware")
|
||||
|
||||
// Verify Traefik started OK
|
||||
checkTraefikStarted(c)
|
||||
|
@ -347,66 +258,16 @@ func getDigestAuthorization(digestParts map[string]string) string {
|
|||
return authorization
|
||||
}
|
||||
|
||||
func (s *AccessLogSuite) TestAccessLogEntrypointRedirect(c *check.C) {
|
||||
ensureWorkingDirectoryIsClean()
|
||||
|
||||
expected := []accessLogValue{
|
||||
{
|
||||
formatOnly: false,
|
||||
code: "302",
|
||||
user: "-",
|
||||
frontendName: "entrypoint redirect for httpRedirect",
|
||||
backendURL: "/",
|
||||
},
|
||||
{
|
||||
formatOnly: true,
|
||||
},
|
||||
}
|
||||
|
||||
// Start Traefik
|
||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/access_log_config.toml"))
|
||||
defer display(c)
|
||||
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
checkStatsForLogFile(c)
|
||||
|
||||
s.composeProject.Container(c, "entrypointRedirect")
|
||||
|
||||
waitForTraefik(c, "entrypointRedirect")
|
||||
|
||||
// Verify Traefik started OK
|
||||
checkTraefikStarted(c)
|
||||
|
||||
// Test entrypoint redirect
|
||||
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8001/test", nil)
|
||||
c.Assert(err, checker.IsNil)
|
||||
req.Host = ""
|
||||
|
||||
err = try.Request(req, 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.HasBody())
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
// Verify access.log output as expected
|
||||
count := checkAccessLogExactValuesOutput(c, expected)
|
||||
|
||||
c.Assert(count, checker.GreaterOrEqualThan, len(expected))
|
||||
|
||||
// Verify no other Traefik problems
|
||||
checkNoOtherTraefikProblems(c)
|
||||
}
|
||||
|
||||
func (s *AccessLogSuite) TestAccessLogFrontendRedirect(c *check.C) {
|
||||
ensureWorkingDirectoryIsClean()
|
||||
|
||||
expected := []accessLogValue{
|
||||
{
|
||||
formatOnly: false,
|
||||
code: "302",
|
||||
user: "-",
|
||||
frontendName: "frontend redirect for frontend-Path-",
|
||||
backendURL: "/",
|
||||
formatOnly: false,
|
||||
code: "302",
|
||||
user: "-",
|
||||
routerName: "rt-frontendRedirect",
|
||||
serviceURL: "-",
|
||||
},
|
||||
{
|
||||
formatOnly: true,
|
||||
|
@ -458,11 +319,11 @@ func (s *AccessLogSuite) TestAccessLogRateLimit(c *check.C) {
|
|||
formatOnly: true,
|
||||
},
|
||||
{
|
||||
formatOnly: false,
|
||||
code: "429",
|
||||
user: "-",
|
||||
frontendName: "rate limit for frontend-Host-ratelimit",
|
||||
backendURL: "/",
|
||||
formatOnly: false,
|
||||
code: "429",
|
||||
user: "-",
|
||||
routerName: "rt-rateLimit",
|
||||
serviceURL: "-",
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -509,11 +370,11 @@ func (s *AccessLogSuite) TestAccessLogBackendNotFound(c *check.C) {
|
|||
|
||||
expected := []accessLogValue{
|
||||
{
|
||||
formatOnly: false,
|
||||
code: "404",
|
||||
user: "-",
|
||||
frontendName: "backend not found",
|
||||
backendURL: "/",
|
||||
formatOnly: false,
|
||||
code: "404",
|
||||
user: "-",
|
||||
routerName: "-",
|
||||
serviceURL: "-",
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -549,63 +410,16 @@ func (s *AccessLogSuite) TestAccessLogBackendNotFound(c *check.C) {
|
|||
checkNoOtherTraefikProblems(c)
|
||||
}
|
||||
|
||||
func (s *AccessLogSuite) TestAccessLogEntrypointWhitelist(c *check.C) {
|
||||
ensureWorkingDirectoryIsClean()
|
||||
|
||||
expected := []accessLogValue{
|
||||
{
|
||||
formatOnly: false,
|
||||
code: "403",
|
||||
user: "-",
|
||||
frontendName: "ipwhitelister for entrypoint httpWhitelistReject",
|
||||
backendURL: "/",
|
||||
},
|
||||
}
|
||||
|
||||
// Start Traefik
|
||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/access_log_config.toml"))
|
||||
defer display(c)
|
||||
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
checkStatsForLogFile(c)
|
||||
|
||||
s.composeProject.Container(c, "entrypointWhitelist")
|
||||
|
||||
waitForTraefik(c, "entrypointWhitelist")
|
||||
|
||||
// Verify Traefik started OK
|
||||
checkTraefikStarted(c)
|
||||
|
||||
// Test rate limit
|
||||
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8002/", nil)
|
||||
c.Assert(err, checker.IsNil)
|
||||
req.Host = "entrypoint.whitelist.docker.local"
|
||||
|
||||
err = try.Request(req, 500*time.Millisecond, try.StatusCodeIs(http.StatusForbidden), try.HasBody())
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
// Verify access.log output as expected
|
||||
count := checkAccessLogExactValuesOutput(c, expected)
|
||||
|
||||
c.Assert(count, checker.GreaterOrEqualThan, len(expected))
|
||||
|
||||
// Verify no other Traefik problems
|
||||
checkNoOtherTraefikProblems(c)
|
||||
}
|
||||
|
||||
func (s *AccessLogSuite) TestAccessLogFrontendWhitelist(c *check.C) {
|
||||
ensureWorkingDirectoryIsClean()
|
||||
|
||||
expected := []accessLogValue{
|
||||
{
|
||||
formatOnly: false,
|
||||
code: "403",
|
||||
user: "-",
|
||||
frontendName: "ipwhitelister for frontend-Host-frontend-whitelist",
|
||||
backendURL: "/",
|
||||
formatOnly: false,
|
||||
code: "403",
|
||||
user: "-",
|
||||
routerName: "rt-frontendWhitelist",
|
||||
serviceURL: "-",
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -648,11 +462,11 @@ func (s *AccessLogSuite) TestAccessLogAuthFrontendSuccess(c *check.C) {
|
|||
|
||||
expected := []accessLogValue{
|
||||
{
|
||||
formatOnly: false,
|
||||
code: "200",
|
||||
user: "test",
|
||||
frontendName: "Host-frontend-auth-docker",
|
||||
backendURL: "http://172.17.0",
|
||||
formatOnly: false,
|
||||
code: "200",
|
||||
user: "test",
|
||||
routerName: "rt-authFrontend",
|
||||
serviceURL: "http://172.17.0",
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -716,8 +530,7 @@ func checkAccessLogExactValuesOutput(c *check.C, values []accessLogValue) int {
|
|||
lines := extractLines(c)
|
||||
count := 0
|
||||
for i, line := range lines {
|
||||
fmt.Printf(line)
|
||||
fmt.Println()
|
||||
fmt.Println(line)
|
||||
if len(line) > 0 {
|
||||
count++
|
||||
if values[i].formatOnly {
|
||||
|
@ -768,13 +581,14 @@ func CheckAccessLogFormat(c *check.C, line string, i int) {
|
|||
c.Assert(results, checker.HasLen, 14)
|
||||
c.Assert(results[accesslog.OriginStatus], checker.Matches, `^(-|\d{3})$`)
|
||||
c.Assert(results[accesslog.RequestCount], checker.Equals, fmt.Sprintf("%d", i+1))
|
||||
c.Assert(results[accesslog.FrontendName], checker.HasPrefix, "\"Host-")
|
||||
c.Assert(results[accesslog.BackendURL], checker.HasPrefix, "\"http://")
|
||||
c.Assert(results[accesslog.RouterName], checker.HasPrefix, "\"docker.rt-")
|
||||
c.Assert(results[accesslog.ServiceURL], checker.HasPrefix, "\"http://")
|
||||
c.Assert(results[accesslog.Duration], checker.Matches, `^\d+ms$`)
|
||||
}
|
||||
|
||||
func checkAccessLogExactValues(c *check.C, line string, i int, v accessLogValue) {
|
||||
results, err := accesslog.ParseAccessLog(line)
|
||||
// c.Assert(nil, checker.Equals, line)
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(results, checker.HasLen, 14)
|
||||
if len(v.user) > 0 {
|
||||
|
@ -782,14 +596,14 @@ func checkAccessLogExactValues(c *check.C, line string, i int, v accessLogValue)
|
|||
}
|
||||
c.Assert(results[accesslog.OriginStatus], checker.Equals, v.code)
|
||||
c.Assert(results[accesslog.RequestCount], checker.Equals, fmt.Sprintf("%d", i+1))
|
||||
c.Assert(results[accesslog.FrontendName], checker.Matches, `^"?`+v.frontendName+`.*$`)
|
||||
c.Assert(results[accesslog.BackendURL], checker.Matches, `^"?`+v.backendURL+`.*$`)
|
||||
c.Assert(results[accesslog.RouterName], checker.Matches, `^"?(docker\.)?`+v.routerName+`.*$`)
|
||||
c.Assert(results[accesslog.ServiceURL], checker.Matches, `^"?`+v.serviceURL+`.*$`)
|
||||
c.Assert(results[accesslog.Duration], checker.Matches, `^\d+ms$`)
|
||||
}
|
||||
|
||||
func waitForTraefik(c *check.C, containerName string) {
|
||||
// Wait for Traefik to turn ready.
|
||||
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8080/api", nil)
|
||||
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8080/api/providers/docker/routers", nil)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
err = try.Request(req, 2*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains(containerName))
|
||||
|
|
|
@ -2,13 +2,12 @@ package integration
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/containous/traefik/api"
|
||||
"github.com/containous/traefik/integration/try"
|
||||
"github.com/containous/traefik/old/types"
|
||||
"github.com/containous/traefik/testhelpers"
|
||||
"github.com/go-check/check"
|
||||
checker "github.com/vdemeester/shakers"
|
||||
|
@ -56,23 +55,27 @@ func (s *DockerComposeSuite) TestComposeScale(c *check.C) {
|
|||
_, err = try.ResponseUntilStatusCode(req, 1500*time.Millisecond, http.StatusOK)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
resp, err := http.Get("http://127.0.0.1:8080/api/providers/docker")
|
||||
resp, err := http.Get("http://127.0.0.1:8080/api/providers/docker/services")
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
|
||||
var services []api.ServiceRepresentation
|
||||
err = json.NewDecoder(resp.Body).Decode(&services)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
var provider types.Configuration
|
||||
c.Assert(json.Unmarshal(body, &provider), checker.IsNil)
|
||||
// check that we have only one service with n servers
|
||||
c.Assert(services, checker.HasLen, 1)
|
||||
c.Assert(services[0].ID, checker.Equals, composeService+"_integrationtest"+composeProject)
|
||||
c.Assert(services[0].LoadBalancer.Servers, checker.HasLen, serviceCount)
|
||||
|
||||
// check that we have only one backend with n servers
|
||||
c.Assert(provider.Backends, checker.HasLen, 1)
|
||||
resp, err = http.Get("http://127.0.0.1:8080/api/providers/docker/routers")
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer resp.Body.Close()
|
||||
|
||||
myBackend := provider.Backends["backend-"+composeService+"-integrationtest"+composeProject]
|
||||
c.Assert(myBackend, checker.NotNil)
|
||||
c.Assert(myBackend.Servers, checker.HasLen, serviceCount)
|
||||
var routers []api.RouterRepresentation
|
||||
err = json.NewDecoder(resp.Body).Decode(&routers)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
// check that we have only one frontend
|
||||
c.Assert(provider.Frontends, checker.HasLen, 1)
|
||||
// check that we have only one router
|
||||
c.Assert(routers, checker.HasLen, 1)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/containous/traefik/integration/try"
|
||||
"github.com/containous/traefik/old/provider/label"
|
||||
"github.com/docker/docker/pkg/namesgenerator"
|
||||
"github.com/go-check/check"
|
||||
d "github.com/libkermit/docker"
|
||||
|
@ -18,17 +17,12 @@ import (
|
|||
checker "github.com/vdemeester/shakers"
|
||||
)
|
||||
|
||||
var (
|
||||
// Label added to started container to identify them as part of the integration test
|
||||
TestLabel = "io.traefik.test"
|
||||
|
||||
// Images to have or pull before the build in order to make it work
|
||||
// FIXME handle this offline but loading them before build
|
||||
RequiredImages = map[string]string{
|
||||
"swarm": "1.0.0",
|
||||
"emilevauge/whoami": "latest",
|
||||
}
|
||||
)
|
||||
// Images to have or pull before the build in order to make it work
|
||||
// FIXME handle this offline but loading them before build
|
||||
var RequiredImages = map[string]string{
|
||||
"swarm": "1.0.0",
|
||||
"containous/whoami": "latest",
|
||||
}
|
||||
|
||||
// Docker test suites
|
||||
type DockerSuite struct {
|
||||
|
@ -107,6 +101,7 @@ func (s *DockerSuite) TestSimpleConfiguration(c *check.C) {
|
|||
func (s *DockerSuite) TestDefaultDockerContainers(c *check.C) {
|
||||
file := s.adaptFileForHost(c, "fixtures/docker/simple.toml")
|
||||
defer os.Remove(file)
|
||||
|
||||
name := s.startContainer(c, "swarm:1.0.0", "manage", "token://blablabla")
|
||||
|
||||
// Start traefik
|
||||
|
@ -136,17 +131,19 @@ func (s *DockerSuite) TestDefaultDockerContainers(c *check.C) {
|
|||
func (s *DockerSuite) TestDockerContainersWithLabels(c *check.C) {
|
||||
file := s.adaptFileForHost(c, "fixtures/docker/simple.toml")
|
||||
defer os.Remove(file)
|
||||
|
||||
// Start a container with some labels
|
||||
labels := map[string]string{
|
||||
label.TraefikFrontendRule: "Host:my.super.host",
|
||||
"traefik.Routers.Super.Rule": "Host:my.super.host",
|
||||
}
|
||||
s.startContainerWithLabels(c, "swarm:1.0.0", labels, "manage", "token://blabla")
|
||||
|
||||
// Start another container by replacing a '.' by a '-'
|
||||
labels = map[string]string{
|
||||
label.TraefikFrontendRule: "Host:my-super.host",
|
||||
"traefik.Routers.SuperHost.Rule": "Host:my-super.host",
|
||||
}
|
||||
s.startContainerWithLabels(c, "swarm:1.0.0", labels, "manage", "token://blablabla")
|
||||
|
||||
// Start traefik
|
||||
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||
defer display(c)
|
||||
|
@ -182,9 +179,10 @@ func (s *DockerSuite) TestDockerContainersWithLabels(c *check.C) {
|
|||
func (s *DockerSuite) TestDockerContainersWithOneMissingLabels(c *check.C) {
|
||||
file := s.adaptFileForHost(c, "fixtures/docker/simple.toml")
|
||||
defer os.Remove(file)
|
||||
|
||||
// Start a container with some labels
|
||||
labels := map[string]string{
|
||||
"traefik.frontend.value": "my.super.host",
|
||||
"traefik.random.value": "my.super.host",
|
||||
}
|
||||
s.startContainerWithLabels(c, "swarm:1.0.0", labels, "manage", "token://blabla")
|
||||
|
||||
|
@ -206,50 +204,14 @@ func (s *DockerSuite) TestDockerContainersWithOneMissingLabels(c *check.C) {
|
|||
c.Assert(err, checker.IsNil)
|
||||
}
|
||||
|
||||
// TestDockerContainersWithServiceLabels allows cheking the labels behavior
|
||||
// Use service label if defined and compete information with container labels.
|
||||
func (s *DockerSuite) TestDockerContainersWithServiceLabels(c *check.C) {
|
||||
file := s.adaptFileForHost(c, "fixtures/docker/simple.toml")
|
||||
defer os.Remove(file)
|
||||
// Start a container with some labels
|
||||
labels := map[string]string{
|
||||
label.Prefix + "servicename.frontend.rule": "Host:my.super.host",
|
||||
label.TraefikFrontendRule: "Host:my.wrong.host",
|
||||
label.TraefikPort: "2375",
|
||||
}
|
||||
s.startContainerWithLabels(c, "swarm:1.0.0", labels, "manage", "token://blabla")
|
||||
|
||||
// Start traefik
|
||||
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||
defer display(c)
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/version", nil)
|
||||
c.Assert(err, checker.IsNil)
|
||||
req.Host = "my.super.host"
|
||||
|
||||
// FIXME Need to wait than 500 milliseconds more (for swarm or traefik to boot up ?)
|
||||
resp, err := try.ResponseUntilStatusCode(req, 1500*time.Millisecond, http.StatusOK)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
var version map[string]interface{}
|
||||
|
||||
c.Assert(json.Unmarshal(body, &version), checker.IsNil)
|
||||
c.Assert(version["Version"], checker.Equals, "swarm/1.0.0")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRestartDockerContainers(c *check.C) {
|
||||
file := s.adaptFileForHost(c, "fixtures/docker/simple.toml")
|
||||
defer os.Remove(file)
|
||||
|
||||
// Start a container with some labels
|
||||
labels := map[string]string{
|
||||
label.Prefix + "frontend.rule": "Host:my.super.host",
|
||||
label.TraefikPort: "2375",
|
||||
"traefik.Routers.Super.Rule": "Host:my.super.host",
|
||||
"traefik.Services.powpow.LoadBalancer.server.Port": "2375",
|
||||
}
|
||||
s.startContainerWithNameAndLabels(c, "powpow", "swarm:1.0.0", labels, "manage", "token://blabla")
|
||||
|
||||
|
@ -276,7 +238,7 @@ func (s *DockerSuite) TestRestartDockerContainers(c *check.C) {
|
|||
c.Assert(json.Unmarshal(body, &version), checker.IsNil)
|
||||
c.Assert(version["Version"], checker.Equals, "swarm/1.0.0")
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/backends", 60*time.Second, try.BodyContains("powpow"))
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/services", 60*time.Second, try.BodyContains("powpow"))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
s.stopAndRemoveContainerByName(c, "powpow")
|
||||
|
@ -284,11 +246,11 @@ func (s *DockerSuite) TestRestartDockerContainers(c *check.C) {
|
|||
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/backends", 10*time.Second, try.BodyContains("powpow"))
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/services", 10*time.Second, try.BodyContains("powpow"))
|
||||
c.Assert(err, checker.NotNil)
|
||||
|
||||
s.startContainerWithNameAndLabels(c, "powpow", "swarm:1.0.0", labels, "manage", "token://blabla")
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/backends", 60*time.Second, try.BodyContains("powpow"))
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/services", 60*time.Second, try.BodyContains("powpow"))
|
||||
c.Assert(err, checker.IsNil)
|
||||
}
|
||||
|
|
|
@ -11,18 +11,6 @@ checkNewVersion = false
|
|||
[entryPoints]
|
||||
[entryPoints.http]
|
||||
address = ":8000"
|
||||
[entryPoints.httpRedirect]
|
||||
address = ":8001"
|
||||
[entryPoints.httpRedirect.redirect]
|
||||
entryPoint = "http"
|
||||
[entryPoints.httpWhitelistReject]
|
||||
address = ":8002"
|
||||
[entryPoints.httpWhitelistReject.whiteList]
|
||||
sourceRange = ["8.8.8.8/32"]
|
||||
[entryPoints.httpAuth]
|
||||
address = ":8004"
|
||||
[entryPoints.httpAuth.auth.basic]
|
||||
users = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"]
|
||||
[entryPoints.frontendRedirect]
|
||||
address = ":8005"
|
||||
[entryPoints.httpFrontendAuth]
|
||||
|
@ -31,8 +19,6 @@ checkNewVersion = false
|
|||
address = ":8007"
|
||||
[entryPoints.digestAuth]
|
||||
address = ":8008"
|
||||
[entryPoints.digestAuth.auth.digest]
|
||||
users = ["test:traefik:a2688e031edb4be6a3797f3882655c05", "test2:traefik:518845800f9e2bfb1f1f740ec24f074e"]
|
||||
|
||||
[api]
|
||||
|
||||
|
|
|
@ -10,10 +10,12 @@ logLevel = "DEBUG"
|
|||
|
||||
|
||||
[api]
|
||||
middlewares = ["authentication"]
|
||||
|
||||
[middlewares]
|
||||
[middlewares.authentication.basic-auth]
|
||||
users = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"]
|
||||
middlewares = ["file.authentication"]
|
||||
|
||||
[ping]
|
||||
|
||||
[providers.file]
|
||||
|
||||
[middlewares]
|
||||
[middlewares.authentication.basicauth]
|
||||
users = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"]
|
||||
|
|
|
@ -41,8 +41,6 @@ func init() {
|
|||
// FIXME Provider tests
|
||||
// check.Suite(&ConsulCatalogSuite{})
|
||||
// check.Suite(&ConsulSuite{})
|
||||
// check.Suite(&DockerComposeSuite{})
|
||||
// check.Suite(&DockerSuite{})
|
||||
// check.Suite(&DynamoDBSuite{})
|
||||
// check.Suite(&EurekaSuite{})
|
||||
// check.Suite(&MarathonSuite{})
|
||||
|
@ -50,31 +48,34 @@ func init() {
|
|||
// check.Suite(&MesosSuite{})
|
||||
|
||||
// FIXME use docker
|
||||
// check.Suite(&AccessLogSuite{})
|
||||
|
||||
// FIXME use consulcatalog
|
||||
// check.Suite(&ConstraintSuite{})
|
||||
// check.Suite(&TLSClientHeadersSuite{})
|
||||
// check.Suite(&HostResolverSuite{})
|
||||
// check.Suite(&LogRotationSuite{})
|
||||
|
||||
// FIXME e2e tests
|
||||
check.Suite(&AccessLogSuite{})
|
||||
check.Suite(&AcmeSuite{})
|
||||
check.Suite(&DockerComposeSuite{})
|
||||
check.Suite(&DockerSuite{})
|
||||
check.Suite(&ErrorPagesSuite{})
|
||||
check.Suite(&FileSuite{})
|
||||
check.Suite(&RestSuite{})
|
||||
check.Suite(&GRPCSuite{})
|
||||
check.Suite(&HealthCheckSuite{})
|
||||
check.Suite(&HostResolverSuite{})
|
||||
check.Suite(&HTTPSSuite{})
|
||||
check.Suite(&LogRotationSuite{})
|
||||
check.Suite(&RateLimitSuite{})
|
||||
check.Suite(&RestSuite{})
|
||||
check.Suite(&RetrySuite{})
|
||||
check.Suite(&SimpleSuite{})
|
||||
check.Suite(&TimeoutSuite{})
|
||||
check.Suite(&TLSClientHeadersSuite{})
|
||||
check.Suite(&TracingSuite{})
|
||||
check.Suite(&WebsocketSuite{})
|
||||
}
|
||||
if *host {
|
||||
// tests launched from the host
|
||||
check.Suite(&ProxyProtocolSuite{})
|
||||
|
||||
// FIXME Provider tests
|
||||
// check.Suite(&Etcd3Suite{})
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ func verifyEmptyErrorLog(c *check.C, name string) {
|
|||
if e2 != nil {
|
||||
return e2
|
||||
}
|
||||
c.Assert(traefikLog, checker.HasLen, 0)
|
||||
c.Assert(string(traefikLog), checker.HasLen, 0)
|
||||
return nil
|
||||
})
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
|
|
@ -102,7 +102,7 @@ func (s *MarathonSuite15) TestConfigurationUpdate(c *check.C) {
|
|||
app.Container.
|
||||
Expose(80).
|
||||
Docker.
|
||||
Container("emilevauge/whoami")
|
||||
Container("containous/whoami")
|
||||
*app.Networks = append(*app.Networks, *marathon.NewBridgePodNetwork())
|
||||
|
||||
// Deploy the test application.
|
||||
|
@ -122,7 +122,7 @@ func (s *MarathonSuite15) TestConfigurationUpdate(c *check.C) {
|
|||
app.Container.
|
||||
Expose(80).
|
||||
Docker.
|
||||
Container("emilevauge/whoami")
|
||||
Container("containous/whoami")
|
||||
*app.Networks = append(*app.Networks, *marathon.NewBridgePodNetwork())
|
||||
|
||||
// Deploy the test application.
|
||||
|
|
|
@ -112,7 +112,7 @@ func (s *MarathonSuite) TestConfigurationUpdate(c *check.C) {
|
|||
AddLabel(label.TraefikFrontendRule, "PathPrefix:/service")
|
||||
app.Container.Docker.Bridged().
|
||||
Expose(80).
|
||||
Container("emilevauge/whoami")
|
||||
Container("containous/whoami")
|
||||
|
||||
// Deploy the test application.
|
||||
deployApplication(c, client, app)
|
||||
|
@ -129,7 +129,7 @@ func (s *MarathonSuite) TestConfigurationUpdate(c *check.C) {
|
|||
AddLabel(label.Prefix+"app"+label.TraefikFrontendRule, "PathPrefix:/app")
|
||||
app.Container.Docker.Bridged().
|
||||
Expose(80).
|
||||
Container("emilevauge/whoami")
|
||||
Container("containous/whoami")
|
||||
|
||||
// Deploy the test application.
|
||||
deployApplication(c, client, app)
|
||||
|
|
|
@ -1,107 +1,79 @@
|
|||
server0:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.backend=backend1
|
||||
- traefik.frontend.entryPoints=http
|
||||
- traefik.frontend.rule=Path:/test
|
||||
- traefik.routers.rt-server0.entryPoints=http
|
||||
- traefik.routers.rt-server0.rule=Path:/test
|
||||
- traefik.services.service1.loadbalancer.server.port=80
|
||||
server1:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.backend=backend1
|
||||
- traefik.frontend.entryPoints=http
|
||||
- traefik.frontend.rule=Host:frontend1.docker.local
|
||||
- traefik.routers.rt-server1.entryPoints=http
|
||||
- traefik.routers.rt-server1.rule=Host:frontend1.docker.local
|
||||
- traefik.services.service1.loadbalancer.server.port=80
|
||||
server2:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.backend=backend2
|
||||
- traefik.frontend.entryPoints=http
|
||||
- traefik.frontend.rule=Host:frontend2.docker.local
|
||||
- traefik.frontend.passHostHeader=true
|
||||
- backend.loadbalancer.method=drr
|
||||
- traefik.routers.rt-server2.entryPoints=http
|
||||
- traefik.routers.rt-server2.rule=Host:frontend2.docker.local
|
||||
- traefik.services.service2.loadbalancer.server.port=80
|
||||
- traefik.services.service2.loadbalancer.method=drr
|
||||
server3:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.backend=backend2
|
||||
- traefik.frontend.entryPoints=http
|
||||
- traefik.frontend.rule=Host:frontend2.docker.local
|
||||
- traefik.frontend.passHostHeader=true
|
||||
- backend.loadbalancer.method=drr
|
||||
- traefik.routers.rt-server3.entryPoints=http
|
||||
- traefik.routers.rt-server3.rule=Host:frontend2.docker.local
|
||||
- traefik.services.service2.loadbalancer.server.port=80
|
||||
- traefik.services.service2.loadbalancer.method=drr
|
||||
authFrontend:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.backend=backend3
|
||||
- traefik.frontend.entryPoints=httpFrontendAuth
|
||||
- traefik.frontend.rule=Host:frontend.auth.docker.local
|
||||
- traefik.frontend.auth.basic=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/
|
||||
authEntrypoint:
|
||||
image: emilevauge/whoami
|
||||
- traefik.routers.rt-authFrontend.entryPoints=httpFrontendAuth
|
||||
- traefik.routers.rt-authFrontend.rule=Host:frontend.auth.docker.local
|
||||
- traefik.routers.rt-authFrontend.middlewares=basicauth
|
||||
- traefik.middlewares.basicauth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/
|
||||
- traefik.services.service3.loadbalancer.server.port=80
|
||||
digestAuthMiddleware:
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.backend=backend3
|
||||
- traefik.frontend.entryPoints=httpAuth
|
||||
- traefik.frontend.rule=Host:entrypoint.auth.docker.local
|
||||
digestAuthEntrypoint:
|
||||
image: emilevauge/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.backend=backend3
|
||||
- traefik.frontend.entryPoints=digestAuth
|
||||
- traefik.frontend.rule=Host:entrypoint.digest.auth.docker.local
|
||||
entrypointRedirect:
|
||||
image: emilevauge/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.backend=backend3
|
||||
- traefik.frontend.entryPoints=httpRedirect
|
||||
- traefik.frontend.rule=Path:/test
|
||||
- traefik.routers.rt-digestAuthMiddleware.entryPoints=digestAuth
|
||||
- traefik.routers.rt-digestAuthMiddleware.rule=Host:entrypoint.digest.auth.docker.local
|
||||
- traefik.routers.rt-digestAuthMiddleware.middlewares=digestauth
|
||||
- traefik.middlewares.digestauth.digestauth.users=test:traefik:a2688e031edb4be6a3797f3882655c05, test2:traefik:518845800f9e2bfb1f1f740ec24f074e
|
||||
- traefik.services.service3.loadbalancer.server.port=80
|
||||
frontendRedirect:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.backend=backend3
|
||||
- traefik.frontend.entryPoints=frontendRedirect
|
||||
- traefik.frontend.rule=Path:/test
|
||||
- traefik.frontend.redirect.entryPoint=http
|
||||
- traefik.routers.rt-frontendRedirect.entryPoints=frontendRedirect
|
||||
- traefik.routers.rt-frontendRedirect.rule=Path:/test
|
||||
- traefik.routers.rt-frontendRedirect.middlewares=redirecthttp
|
||||
- traefik.middlewares.redirecthttp.redirect.regex=^(?:https?://)?([\w\._-]+)(?::\d+)?(.*)$$
|
||||
- traefik.middlewares.redirecthttp.redirect.replacement=http://$${1}:8000$${2}
|
||||
- traefik.services.service3.loadbalancer.server.port=80
|
||||
rateLimit:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.backend=backend3
|
||||
- traefik.frontend.entryPoints=httpRateLimit
|
||||
- traefik.frontend.rule=Host:ratelimit.docker.local
|
||||
- traefik.frontend.rateLimit.extractorFunc=client.ip
|
||||
- traefik.frontend.rateLimit.rateSet.powpow.period=3s
|
||||
- traefik.frontend.rateLimit.rateSet.powpow.average=1
|
||||
- traefik.frontend.rateLimit.rateSet.powpow.burst=2
|
||||
entrypointWhitelist:
|
||||
image: emilevauge/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.backend=backend3
|
||||
- traefik.frontend.entryPoints=httpWhitelistReject
|
||||
- traefik.frontend.rule=Host:entrypoint.whitelist.docker.local
|
||||
- traefik.routers.rt-rateLimit.entryPoints=httpRateLimit
|
||||
- traefik.routers.rt-rateLimit.rule=Host:ratelimit.docker.local
|
||||
- traefik.routers.rt-rateLimit.middlewares=rate
|
||||
- traefik.middlewares.rate.ratelimit.extractorfunc=client.ip
|
||||
- traefik.middlewares.rate.ratelimit.rateset.Rate0.average=1
|
||||
- traefik.middlewares.rate.ratelimit.rateset.Rate0.burst=2
|
||||
- traefik.middlewares.rate.ratelimit.rateset.Rate0.period=10s
|
||||
- traefik.services.service3.loadbalancer.server.port=80
|
||||
frontendWhitelist:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.backend=backend3
|
||||
- traefik.frontend.whiteList.sourceRange=8.8.8.8/32
|
||||
- traefik.frontend.entryPoints=http
|
||||
- traefik.frontend.rule=Host:frontend.whitelist.docker.local
|
||||
- traefik.routers.rt-frontendWhitelist.entryPoints=http
|
||||
- traefik.routers.rt-frontendWhitelist.rule=Host:frontend.whitelist.docker.local
|
||||
- traefik.routers.rt-frontendWhitelist.middlewares=wl
|
||||
- traefik.middlewares.wl.ipwhitelist.sourcerange=8.8.8.8/32
|
||||
- traefik.services.service3.loadbalancer.server.port=80
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
whoami1:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.frontend.rule=AddPrefix:/whoami;PathPrefix:/
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
whoami1:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.frontend.rule=PathPrefix:/whoami
|
||||
- traefik.backend="test"
|
||||
- traefik.routers.router1.rule=PathPrefix:/whoami
|
||||
|
||||
whoami2:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=false
|
||||
- traefik.enable=false
|
||||
|
|
|
@ -12,6 +12,6 @@ consul:
|
|||
- "8302"
|
||||
- "8302/udp"
|
||||
whoami:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
ports:
|
||||
- "8881:80"
|
||||
|
|
|
@ -13,13 +13,13 @@ consul:
|
|||
- "8302/udp"
|
||||
|
||||
whoami1:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
||||
whoami2:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
||||
whoami3:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
||||
whoami4:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
|
|
@ -12,8 +12,8 @@ consul:
|
|||
- "8302"
|
||||
- "8302/udp"
|
||||
whoami1:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
whoami2:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
whoami3:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
|
|
@ -7,10 +7,10 @@ dynamo:
|
|||
- "8000"
|
||||
|
||||
whoami1:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
||||
whoami2:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
||||
whoami3:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
|
|
@ -12,22 +12,22 @@ services:
|
|||
- 7001
|
||||
|
||||
whoami1:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
depends_on:
|
||||
- etcd
|
||||
|
||||
whoami2:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
depends_on:
|
||||
- whoami1
|
||||
|
||||
whoami3:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
depends_on:
|
||||
- whoami2
|
||||
|
||||
whoami4:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
depends_on:
|
||||
- whoami3
|
||||
|
||||
|
|
|
@ -2,4 +2,4 @@ eureka:
|
|||
image: springcloud/eureka
|
||||
|
||||
whoami1:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
whoami1:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
ports:
|
||||
- "8881:80"
|
||||
whoami2:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
ports:
|
||||
- "8882:80"
|
||||
whoami3:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
ports:
|
||||
- "8883:80"
|
||||
whoami4:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
ports:
|
||||
- "8884:80"
|
||||
whoami5:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
ports:
|
||||
- "8885:80"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
whoami1:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
||||
whoami2:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
server1:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.backend=backend1
|
||||
- traefik.frontend.entryPoints=http
|
||||
- traefik.frontend.rule=Host:github.com
|
||||
- traefik.services.service1.loadbalancer.server.port=80
|
||||
- traefik.routers.router1.rule=Host:github.com
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
whoami1:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.frontend.rule=PathPrefix:/whoami
|
||||
- traefik.enable=true
|
||||
- traefik.Routers.RouterMini.Rule=PathPrefix:/whoami
|
||||
- traefik.enable=true
|
||||
|
||||
|
|
|
@ -4,4 +4,4 @@ haproxy:
|
|||
- ../haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
|
||||
|
||||
whoami:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
whoami1:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
whoami:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
whoami:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
whoami1:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
||||
whoami2:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
|
@ -2,5 +2,6 @@ whoami:
|
|||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.frontend.passTLSClientCert.pem=true
|
||||
- traefik.frontend.rule=PathPrefix:/
|
||||
|
||||
- traefik.routers.route1.rule=PathPrefix:/
|
||||
- traefik.routers.route1.middlewares=passtls
|
||||
- traefik.middlewares.passtls.passtlsclientcert.pem=true
|
||||
|
|
|
@ -20,4 +20,4 @@ jaeger:
|
|||
- "14268:14268"
|
||||
- "9411:9411"
|
||||
whoami:
|
||||
image: emilevauge/whoami
|
||||
image: containous/whoami
|
|
@ -2,33 +2,33 @@ noOverrideWhitelist:
|
|||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.frontend.rule=Host:no.override.whitelist.docker.local
|
||||
- traefik.frontend.whiteList.sourceRange=8.8.8.8
|
||||
- traefik.routers.rt1.rule=Host:no.override.whitelist.docker.local
|
||||
- traefik.routers.rt1.middlewares=wl1
|
||||
- traefik.middlewares.wl1.ipwhiteList.sourceRange=8.8.8.8
|
||||
|
||||
overrideIPStrategyRemoteAddrWhitelist:
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.frontend.rule=Host:override.remoteaddr.whitelist.docker.local
|
||||
- traefik.frontend.whiteList.sourceRange=8.8.8.8
|
||||
- traefik.frontend.whiteList.ipStrategy=true
|
||||
- traefik.routers.rt2.rule=Host:override.remoteaddr.whitelist.docker.local
|
||||
- traefik.routers.rt2.middlewares=wl2
|
||||
- traefik.middlewares.wl2.ipwhitelist.sourceRange=8.8.8.8
|
||||
- traefik.middlewares.wl2.ipwhitelist.ipStrategy=true
|
||||
|
||||
overrideIPStrategyDepthWhitelist:
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.frontend.rule=Host:override.depth.whitelist.docker.local
|
||||
- traefik.frontend.whiteList.sourceRange=8.8.8.8
|
||||
- traefik.frontend.whiteList.ipStrategy.depth=3
|
||||
- traefik.routers.rt3.rule=Host:override.depth.whitelist.docker.local
|
||||
- traefik.routers.rt3.middlewares=wl3
|
||||
- traefik.middlewares.wl3.ipwhitelist.sourceRange=8.8.8.8
|
||||
- traefik.middlewares.wl3.ipwhitelist.ipStrategy.depth=3
|
||||
|
||||
overrideIPStrategyExcludedIPsWhitelist:
|
||||
image: containous/whoami
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.port=80
|
||||
- traefik.frontend.rule=Host:override.excludedips.whitelist.docker.local
|
||||
- traefik.frontend.whiteList.sourceRange=8.8.8.8
|
||||
- traefik.frontend.whiteList.ipStrategy.excludedIPs=10.0.0.1,10.0.0.2
|
||||
- traefik.routers.rt4.rule=Host:override.excludedips.whitelist.docker.local
|
||||
- traefik.routers.rt4.middlewares=wl4
|
||||
- traefik.middlewares.wl4.ipwhitelist.sourceRange=8.8.8.8
|
||||
- traefik.middlewares.wl4.ipwhitelist.ipStrategy.excludedIPs=10.0.0.1,10.0.0.2
|
||||
|
|
|
@ -158,8 +158,6 @@ func (s *SimpleSuite) TestRequestAcceptGraceTimeout(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *SimpleSuite) TestApiOnSameEntryPoint(c *check.C) {
|
||||
c.Skip("Use docker")
|
||||
|
||||
s.createComposeProject(c, "base")
|
||||
s.composeProject.Start(c)
|
||||
|
||||
|
@ -175,10 +173,10 @@ func (s *SimpleSuite) TestApiOnSameEntryPoint(c *check.C) {
|
|||
err = try.GetRequest("http://127.0.0.1:8000/test", 1*time.Second, try.StatusCodeIs(http.StatusNotFound))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8000/api", 1*time.Second, try.StatusCodeIs(http.StatusOK))
|
||||
err = try.GetRequest("http://127.0.0.1:8000/api/providers/docker", 1*time.Second, try.StatusCodeIs(http.StatusOK))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8000/api/providers/file/routers", 1*time.Second, try.BodyContains("PathPrefix"))
|
||||
err = try.GetRequest("http://127.0.0.1:8000/api/providers/docker/routers", 1*time.Second, try.BodyContains("PathPrefix"))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8000/whoami", 1*time.Second, try.StatusCodeIs(http.StatusOK))
|
||||
|
@ -186,8 +184,7 @@ func (s *SimpleSuite) TestApiOnSameEntryPoint(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *SimpleSuite) TestStatsWithMultipleEntryPoint(c *check.C) {
|
||||
c.Skip("Use docker")
|
||||
|
||||
c.Skip("Stats is missing")
|
||||
s.createComposeProject(c, "stats")
|
||||
s.composeProject.Start(c)
|
||||
|
||||
|
@ -223,7 +220,6 @@ func (s *SimpleSuite) TestStatsWithMultipleEntryPoint(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *SimpleSuite) TestNoAuthOnPing(c *check.C) {
|
||||
c.Skip("Middlewares on entryPoint don't work anymore")
|
||||
s.createComposeProject(c, "base")
|
||||
s.composeProject.Start(c)
|
||||
|
||||
|
@ -234,7 +230,7 @@ func (s *SimpleSuite) TestNoAuthOnPing(c *check.C) {
|
|||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8001/api", 1*time.Second, try.StatusCodeIs(http.StatusUnauthorized))
|
||||
err = try.GetRequest("http://127.0.0.1:8001/api/providers", 2*time.Second, try.StatusCodeIs(http.StatusUnauthorized))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8001/ping", 1*time.Second, try.StatusCodeIs(http.StatusOK))
|
||||
|
@ -242,8 +238,6 @@ func (s *SimpleSuite) TestNoAuthOnPing(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *SimpleSuite) TestDefaultEntrypointHTTP(c *check.C) {
|
||||
c.Skip("Use docker")
|
||||
|
||||
s.createComposeProject(c, "base")
|
||||
s.composeProject.Start(c)
|
||||
|
||||
|
@ -254,7 +248,7 @@ func (s *SimpleSuite) TestDefaultEntrypointHTTP(c *check.C) {
|
|||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/file/routers", 1*time.Second, try.BodyContains("PathPrefix"))
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/routers", 1*time.Second, try.BodyContains("PathPrefix"))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8000/whoami", 1*time.Second, try.StatusCodeIs(http.StatusOK))
|
||||
|
@ -262,8 +256,6 @@ func (s *SimpleSuite) TestDefaultEntrypointHTTP(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *SimpleSuite) TestWithUnexistingEntrypoint(c *check.C) {
|
||||
c.Skip("Use docker")
|
||||
|
||||
s.createComposeProject(c, "base")
|
||||
s.composeProject.Start(c)
|
||||
|
||||
|
@ -274,7 +266,7 @@ func (s *SimpleSuite) TestWithUnexistingEntrypoint(c *check.C) {
|
|||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/file/routers", 1*time.Second, try.BodyContains("PathPrefix"))
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/routers", 1*time.Second, try.BodyContains("PathPrefix"))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8000/whoami", 1*time.Second, try.StatusCodeIs(http.StatusOK))
|
||||
|
@ -282,19 +274,17 @@ func (s *SimpleSuite) TestWithUnexistingEntrypoint(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *SimpleSuite) TestMetricsPrometheusDefaultEntrypoint(c *check.C) {
|
||||
c.Skip("Use docker")
|
||||
|
||||
s.createComposeProject(c, "base")
|
||||
s.composeProject.Start(c)
|
||||
|
||||
cmd, output := s.traefikCmd("--entryPoints=Name:http Address::8000", "--api", "--metrics.prometheus.buckets=0.1,0.3,1.2,5.0", "--docker", "--global.debug")
|
||||
cmd, output := s.traefikCmd("--entryPoints=Name:http Address::8000", "--api", "--metrics.prometheus.buckets=0.1,0.3,1.2,5.0", "--providers.docker", "--global.debug")
|
||||
defer output(c)
|
||||
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/file/routers", 1*time.Second, try.BodyContains("PathPrefix"))
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/routers", 1*time.Second, try.BodyContains("PathPrefix"))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8000/whoami", 1*time.Second, try.StatusCodeIs(http.StatusOK))
|
||||
|
@ -305,8 +295,6 @@ func (s *SimpleSuite) TestMetricsPrometheusDefaultEntrypoint(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *SimpleSuite) TestMultipleProviderSameBackendName(c *check.C) {
|
||||
c.Skip("Use docker")
|
||||
|
||||
s.createComposeProject(c, "base")
|
||||
s.composeProject.Start(c)
|
||||
|
||||
|
@ -336,8 +324,6 @@ func (s *SimpleSuite) TestMultipleProviderSameBackendName(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *SimpleSuite) TestIPStrategyWhitelist(c *check.C) {
|
||||
c.Skip("Use docker")
|
||||
|
||||
s.createComposeProject(c, "whitelist")
|
||||
s.composeProject.Start(c)
|
||||
|
||||
|
@ -348,7 +334,10 @@ func (s *SimpleSuite) TestIPStrategyWhitelist(c *check.C) {
|
|||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/file/routers", 1*time.Second, try.BodyContains("override"))
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/routers", 2*time.Second, try.BodyContains("override"))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/routers", 2*time.Second, try.BodyContains("override.remoteaddr.whitelist.docker.local"))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
testCases := []struct {
|
||||
|
@ -357,18 +346,19 @@ func (s *SimpleSuite) TestIPStrategyWhitelist(c *check.C) {
|
|||
host string
|
||||
expectedStatusCode int
|
||||
}{
|
||||
{
|
||||
desc: "default client ip strategy accept",
|
||||
xForwardedFor: "8.8.8.8,127.0.0.1",
|
||||
host: "no.override.whitelist.docker.local",
|
||||
expectedStatusCode: 200,
|
||||
},
|
||||
{
|
||||
desc: "default client ip strategy reject",
|
||||
xForwardedFor: "8.8.8.10,127.0.0.1",
|
||||
host: "no.override.whitelist.docker.local",
|
||||
expectedStatusCode: 403,
|
||||
},
|
||||
// {
|
||||
// desc: "default client ip strategy accept",
|
||||
// xForwardedFor: "8.8.8.8,127.0.0.1",
|
||||
// host: "no.override.whitelist.docker.local",
|
||||
// expectedStatusCode: 200,
|
||||
// },
|
||||
// FIXME add clientipstrategy and forwarded headers on entrypoint
|
||||
// {
|
||||
// desc: "default client ip strategy reject",
|
||||
// xForwardedFor: "8.8.8.10,127.0.0.1",
|
||||
// host: "no.override.whitelist.docker.local",
|
||||
// expectedStatusCode: 403,
|
||||
// },
|
||||
{
|
||||
desc: "override remote addr reject",
|
||||
xForwardedFor: "8.8.8.8,8.8.8.8",
|
||||
|
|
|
@ -50,7 +50,7 @@ func (s *TLSClientHeadersSuite) TestTLSClientHeaders(c *check.C) {
|
|||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers", 2*time.Second, try.BodyContains("PathPrefix:/"))
|
||||
err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/routers", 2*time.Second, try.BodyContains("PathPrefix:/"))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
request, err := http.NewRequest(http.MethodGet, "https://127.0.0.1:8443", nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue