Restrict traefik.toml to static configuration.
This commit is contained in:
parent
f49800e56a
commit
093658836e
78 changed files with 274 additions and 440 deletions
|
@ -24,7 +24,7 @@ func NewCmd(traefikConfiguration *static.Configuration, loaders []cli.ResourceLo
|
||||||
|
|
||||||
func runCmd(traefikConfiguration *static.Configuration) func(_ []string) error {
|
func runCmd(traefikConfiguration *static.Configuration) func(_ []string) error {
|
||||||
return func(_ []string) error {
|
return func(_ []string) error {
|
||||||
traefikConfiguration.SetEffectiveConfiguration("")
|
traefikConfiguration.SetEffectiveConfiguration()
|
||||||
|
|
||||||
resp, errPing := Do(*traefikConfiguration)
|
resp, errPing := Do(*traefikConfiguration)
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
|
|
|
@ -53,7 +53,7 @@ Complete documentation is available at https://traefik.io`,
|
||||||
Configuration: tConfig,
|
Configuration: tConfig,
|
||||||
Resources: loaders,
|
Resources: loaders,
|
||||||
Run: func(_ []string) error {
|
Run: func(_ []string) error {
|
||||||
return runCmd(&tConfig.Configuration, cli.GetConfigFile(loaders))
|
return runCmd(&tConfig.Configuration)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ Complete documentation is available at https://traefik.io`,
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runCmd(staticConfiguration *static.Configuration, configFile string) error {
|
func runCmd(staticConfiguration *static.Configuration) error {
|
||||||
configureLogging(staticConfiguration)
|
configureLogging(staticConfiguration)
|
||||||
|
|
||||||
http.DefaultTransport.(*http.Transport).Proxy = http.ProxyFromEnvironment
|
http.DefaultTransport.(*http.Transport).Proxy = http.ProxyFromEnvironment
|
||||||
|
@ -87,7 +87,7 @@ func runCmd(staticConfiguration *static.Configuration, configFile string) error
|
||||||
log.WithoutContext().Errorf("Could not set roundrobin default weight: %v", err)
|
log.WithoutContext().Errorf("Could not set roundrobin default weight: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
staticConfiguration.SetEffectiveConfiguration(configFile)
|
staticConfiguration.SetEffectiveConfiguration()
|
||||||
staticConfiguration.ValidateConfiguration()
|
staticConfiguration.ValidateConfiguration()
|
||||||
|
|
||||||
log.WithoutContext().Infof("Traefik version %s built on %s", version.Version, version.BuildDate)
|
log.WithoutContext().Infof("Traefik version %s built on %s", version.Version, version.BuildDate)
|
||||||
|
|
|
@ -81,9 +81,6 @@ labels:
|
||||||
|
|
||||||
```toml tab="File"
|
```toml tab="File"
|
||||||
# As Toml Configuration File
|
# As Toml Configuration File
|
||||||
[providers]
|
|
||||||
[providers.file]
|
|
||||||
|
|
||||||
[http.routers]
|
[http.routers]
|
||||||
[http.routers.router1]
|
[http.routers.router1]
|
||||||
service = "myService"
|
service = "myService"
|
||||||
|
@ -128,9 +125,6 @@ and therefore this specification would be ignored even if present.
|
||||||
Declaring the add-foo-prefix in the file provider.
|
Declaring the add-foo-prefix in the file provider.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[providers]
|
|
||||||
[providers.file]
|
|
||||||
|
|
||||||
[http.middlewares]
|
[http.middlewares]
|
||||||
[http.middlewares.add-foo-prefix.addPrefix]
|
[http.middlewares.add-foo-prefix.addPrefix]
|
||||||
prefix = "/foo"
|
prefix = "/foo"
|
||||||
|
|
|
@ -6,7 +6,6 @@ Good Old Configuration File
|
||||||
The file provider lets you define the [dynamic configuration](./overview.md) in a TOML or YAML file.
|
The file provider lets you define the [dynamic configuration](./overview.md) in a TOML or YAML file.
|
||||||
You can write these configuration elements:
|
You can write these configuration elements:
|
||||||
|
|
||||||
* At the end of the main Traefik configuration file (by default: `traefik.toml`/`traefik.yml`/`traefik.yaml`).
|
|
||||||
* In [a dedicated file](#filename)
|
* In [a dedicated file](#filename)
|
||||||
* In [several dedicated files](#directory)
|
* In [several dedicated files](#directory)
|
||||||
|
|
||||||
|
@ -22,13 +21,19 @@ You can write these configuration elements:
|
||||||
|
|
||||||
Enabling the file provider:
|
Enabling the file provider:
|
||||||
|
|
||||||
```toml tab="TOML"
|
```toml tab="File (TOML)"
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "/my/path/to/dynamic-conf.toml"
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml tab="YAML"
|
```yaml tab="File (YAML)"
|
||||||
providers:
|
providers:
|
||||||
file: {}
|
file:
|
||||||
|
filename: "/my/path/to/dynamic-conf.yml"
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--providers.file.filename=/my/path/to/dynamic_conf.toml
|
||||||
```
|
```
|
||||||
|
|
||||||
Declaring Routers, Middlewares & Services:
|
Declaring Routers, Middlewares & Services:
|
||||||
|
@ -102,16 +107,20 @@ _Optional_
|
||||||
|
|
||||||
Defines the path of the configuration file.
|
Defines the path of the configuration file.
|
||||||
|
|
||||||
```toml tab="TOML"
|
```toml tab="File (TOML)"
|
||||||
[providers]
|
[providers]
|
||||||
[providers.file]
|
[providers.file]
|
||||||
filename = "rules.toml"
|
filename = "dynamic_conf.toml"
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml tab="YAML"
|
```yaml tab="File (YAML)"
|
||||||
providers:
|
providers:
|
||||||
file:
|
file:
|
||||||
filename: rules.yaml
|
filename: dynamic_conf.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--providers.file.filename=dynamic_conf.toml
|
||||||
```
|
```
|
||||||
|
|
||||||
### `directory`
|
### `directory`
|
||||||
|
@ -120,18 +129,22 @@ _Optional_
|
||||||
|
|
||||||
Defines the directory that contains the configuration files.
|
Defines the directory that contains the configuration files.
|
||||||
|
|
||||||
```toml tab="TOML"
|
```toml tab="File (TOML)"
|
||||||
[providers]
|
[providers]
|
||||||
[providers.file]
|
[providers.file]
|
||||||
directory = "/path/to/config"
|
directory = "/path/to/config"
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml tab="YAML"
|
```yaml tab="File (YAML)"
|
||||||
providers:
|
providers:
|
||||||
file:
|
file:
|
||||||
directory: /path/to/config
|
directory: /path/to/config
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--providers.file.directory=/path/to/config
|
||||||
|
```
|
||||||
|
|
||||||
### `watch`
|
### `watch`
|
||||||
|
|
||||||
_Optional_
|
_Optional_
|
||||||
|
@ -139,20 +152,25 @@ _Optional_
|
||||||
Set the `watch` option to `true` to allow Traefik to automatically watch for file changes.
|
Set the `watch` option to `true` to allow Traefik to automatically watch for file changes.
|
||||||
It works with both the `filename` and the `directory` options.
|
It works with both the `filename` and the `directory` options.
|
||||||
|
|
||||||
```toml tab="TOML"
|
```toml tab="File (TOML)"
|
||||||
[providers]
|
[providers]
|
||||||
[providers.file]
|
[providers.file]
|
||||||
filename = "rules.toml"
|
filename = "dynamic_conf.toml"
|
||||||
watch = true
|
watch = true
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml tab="YAML"
|
```yaml tab="File (YAML)"
|
||||||
providers:
|
providers:
|
||||||
file:
|
file:
|
||||||
filename: rules.yml
|
filename: dynamic_conf.yml
|
||||||
watch: true
|
watch: true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```bash tab="CLI"
|
||||||
|
--providers.file.filename=dynamic_conf.toml
|
||||||
|
--providers.file.watch=true
|
||||||
|
```
|
||||||
|
|
||||||
### Go Templating
|
### Go Templating
|
||||||
|
|
||||||
!!! warning
|
!!! warning
|
||||||
|
|
|
@ -285,9 +285,6 @@ Use the ip address from the bound port, rather than from the inner network. (Def
|
||||||
`--providers.docker.watch`:
|
`--providers.docker.watch`:
|
||||||
Watch provider. (Default: ```true```)
|
Watch provider. (Default: ```true```)
|
||||||
|
|
||||||
`--providers.file`:
|
|
||||||
Enable File backend with default settings. (Default: ```false```)
|
|
||||||
|
|
||||||
`--providers.file.debugloggeneratedtemplate`:
|
`--providers.file.debugloggeneratedtemplate`:
|
||||||
Enable debug logging of generated configuration template. (Default: ```false```)
|
Enable debug logging of generated configuration template. (Default: ```false```)
|
||||||
|
|
||||||
|
|
|
@ -285,9 +285,6 @@ Use the ip address from the bound port, rather than from the inner network. (Def
|
||||||
`TRAEFIK_PROVIDERS_DOCKER_WATCH`:
|
`TRAEFIK_PROVIDERS_DOCKER_WATCH`:
|
||||||
Watch provider. (Default: ```true```)
|
Watch provider. (Default: ```true```)
|
||||||
|
|
||||||
`TRAEFIK_PROVIDERS_FILE`:
|
|
||||||
Enable File backend with default settings. (Default: ```false```)
|
|
||||||
|
|
||||||
`TRAEFIK_PROVIDERS_FILE_DEBUGLOGGENERATEDTEMPLATE`:
|
`TRAEFIK_PROVIDERS_FILE_DEBUGLOGGENERATEDTEMPLATE`:
|
||||||
Enable debug logging of generated configuration template. (Default: ```false```)
|
Enable debug logging of generated configuration template. (Default: ```false```)
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ Static configuration:
|
||||||
[providers]
|
[providers]
|
||||||
# Enable the file provider to define routers / middlewares / services in a file
|
# Enable the file provider to define routers / middlewares / services in a file
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "dynamic_conf.toml"
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml tab="File (YAML)"
|
```yaml tab="File (YAML)"
|
||||||
|
@ -45,7 +46,8 @@ entryPoints:
|
||||||
|
|
||||||
providers:
|
providers:
|
||||||
# Enable the file provider to define routers / middlewares / services in a file
|
# Enable the file provider to define routers / middlewares / services in a file
|
||||||
file: {}
|
file:
|
||||||
|
filename: dynamic_conf.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash tab="CLI"
|
```bash tab="CLI"
|
||||||
|
@ -53,7 +55,7 @@ providers:
|
||||||
--entryPoints.web.address=:8081
|
--entryPoints.web.address=:8081
|
||||||
|
|
||||||
# Enable the file provider to define routers / middlewares / services in a file
|
# Enable the file provider to define routers / middlewares / services in a file
|
||||||
--providers.file
|
--providers.file.filename=dynamic_conf.toml
|
||||||
```
|
```
|
||||||
|
|
||||||
Dynamic configuration:
|
Dynamic configuration:
|
||||||
|
@ -124,7 +126,7 @@ http:
|
||||||
|
|
||||||
Static configuration:
|
Static configuration:
|
||||||
|
|
||||||
```toml tab="TOML"
|
```toml tab="File (TOML)"
|
||||||
[entryPoints]
|
[entryPoints]
|
||||||
[entryPoints.web]
|
[entryPoints.web]
|
||||||
# Listen on port 8081 for incoming requests
|
# Listen on port 8081 for incoming requests
|
||||||
|
@ -133,16 +135,18 @@ http:
|
||||||
[providers]
|
[providers]
|
||||||
# Enable the file provider to define routers / middlewares / services in a file
|
# Enable the file provider to define routers / middlewares / services in a file
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "dynamic_conf.toml"
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml tab="YAML"
|
```yaml tab="File (YAML)"
|
||||||
entryPoints:
|
entryPoints:
|
||||||
web:
|
web:
|
||||||
# Listen on port 8081 for incoming requests
|
# Listen on port 8081 for incoming requests
|
||||||
address: :8081
|
address: :8081
|
||||||
providers:
|
providers:
|
||||||
# Enable the file provider to define routers / middlewares / services in a file
|
# Enable the file provider to define routers / middlewares / services in a file
|
||||||
file: {}
|
file:
|
||||||
|
filename: dynamic_conf.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash tab="CLI"
|
```bash tab="CLI"
|
||||||
|
@ -150,7 +154,7 @@ http:
|
||||||
--entryPoints.web.address=":8081"
|
--entryPoints.web.address=":8081"
|
||||||
|
|
||||||
# Enable the file provider to define routers / middlewares / services in a file
|
# Enable the file provider to define routers / middlewares / services in a file
|
||||||
--providers.file
|
--providers.file.filename=dynamic_conf.toml
|
||||||
```
|
```
|
||||||
|
|
||||||
Dynamic configuration:
|
Dynamic configuration:
|
||||||
|
|
|
@ -6,17 +6,40 @@ This section explains how to use Traefik as reverse proxy for gRPC application.
|
||||||
|
|
||||||
### Traefik Configuration
|
### Traefik Configuration
|
||||||
|
|
||||||
```toml tab="TOML"
|
Static configuration:
|
||||||
## static configuration ##
|
|
||||||
|
|
||||||
|
```toml tab="File (TOML)"
|
||||||
[entryPoints]
|
[entryPoints]
|
||||||
[entryPoints.http]
|
[entryPoints.web]
|
||||||
address = ":80"
|
address = ":80"
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "dynamic_conf.toml"
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml tab="File (YAML)"
|
||||||
|
entryPoints:
|
||||||
|
web:
|
||||||
|
address: :80
|
||||||
|
|
||||||
|
providers:
|
||||||
|
file:
|
||||||
|
filename: dynamic_conf.yml
|
||||||
|
|
||||||
|
api: {}
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml tab="CLI"
|
||||||
|
--entryPoints.web.address=":80"
|
||||||
|
--providers.file.filename=dynamic_conf.toml
|
||||||
|
--api
|
||||||
|
```
|
||||||
|
|
||||||
|
`dynamic_conf.{toml,yml}`:
|
||||||
|
|
||||||
|
```toml tab="TOML"
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
[http]
|
[http]
|
||||||
|
@ -34,17 +57,6 @@ This section explains how to use Traefik as reverse proxy for gRPC application.
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml tab="YAML"
|
```yaml tab="YAML"
|
||||||
## static configuration ##
|
|
||||||
|
|
||||||
entryPoints:
|
|
||||||
http:
|
|
||||||
address: :80
|
|
||||||
|
|
||||||
providers:
|
|
||||||
file: {}
|
|
||||||
|
|
||||||
api: {}
|
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
http:
|
http:
|
||||||
|
@ -105,11 +117,11 @@ Common Name (e.g. server FQDN or YOUR name) []: frontend.local
|
||||||
|
|
||||||
At last, we configure our Traefik instance to use both self-signed certificates.
|
At last, we configure our Traefik instance to use both self-signed certificates.
|
||||||
|
|
||||||
```toml tab="TOML"
|
Static configuration:
|
||||||
## static configuration ##
|
|
||||||
|
|
||||||
|
```toml tab="File (TOML)"
|
||||||
[entryPoints]
|
[entryPoints]
|
||||||
[entryPoints.https]
|
[entryPoints.websecure]
|
||||||
address = ":4443"
|
address = ":4443"
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,7 +132,37 @@ At last, we configure our Traefik instance to use both self-signed certificates.
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[provider.file]
|
[provider.file]
|
||||||
|
filename = "dynamic_conf.toml"
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml tab="File (YAML)"
|
||||||
|
entryPoints:
|
||||||
|
websecure:
|
||||||
|
address: :4443
|
||||||
|
|
||||||
|
serversTransport:
|
||||||
|
# For secure connection on backend.local
|
||||||
|
rootCAs:
|
||||||
|
- ./backend.cert
|
||||||
|
|
||||||
|
providers:
|
||||||
|
file:
|
||||||
|
filename: dynamic_conf.yml
|
||||||
|
|
||||||
|
api: {}
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml tab="CLI"
|
||||||
|
--entryPoints.websecure.address=":4443"
|
||||||
|
# For secure connection on backend.local
|
||||||
|
--serversTransport.rootCAs=./backend.cert
|
||||||
|
--providers.file.filename=dynamic_conf.toml
|
||||||
|
--api
|
||||||
|
```
|
||||||
|
|
||||||
|
`dynamic_conf.{toml,yml}`:
|
||||||
|
|
||||||
|
```toml tab="TOML"
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
[http]
|
[http]
|
||||||
|
@ -146,22 +188,6 @@ At last, we configure our Traefik instance to use both self-signed certificates.
|
||||||
```
|
```
|
||||||
|
|
||||||
```yaml tab="YAML"
|
```yaml tab="YAML"
|
||||||
## static configuration ##
|
|
||||||
|
|
||||||
entryPoints:
|
|
||||||
https:
|
|
||||||
address: :4443
|
|
||||||
|
|
||||||
serversTransport:
|
|
||||||
# For secure connection on backend.local
|
|
||||||
rootCAs:
|
|
||||||
- ./backend.cert
|
|
||||||
|
|
||||||
providers:
|
|
||||||
file: {}
|
|
||||||
|
|
||||||
api: {}
|
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
http:
|
http:
|
||||||
|
|
|
@ -2,6 +2,7 @@ package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containous/traefik/integration/try"
|
"github.com/containous/traefik/integration/try"
|
||||||
|
@ -14,12 +15,13 @@ type FileSuite struct{ BaseSuite }
|
||||||
|
|
||||||
func (s *FileSuite) SetUpSuite(c *check.C) {
|
func (s *FileSuite) SetUpSuite(c *check.C) {
|
||||||
s.createComposeProject(c, "file")
|
s.createComposeProject(c, "file")
|
||||||
|
|
||||||
s.composeProject.Start(c)
|
s.composeProject.Start(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FileSuite) TestSimpleConfiguration(c *check.C) {
|
func (s *FileSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/file/simple.toml"))
|
file := s.adaptFile(c, "fixtures/file/simple.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
[entryPoints.web]
|
[entryPoints.web]
|
||||||
address = ":8080"
|
address = ":8080"
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
[entryPoints.web]
|
[entryPoints.web]
|
||||||
address = ":8080"
|
address = ":8080"
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -9,5 +9,5 @@
|
||||||
[entryPoints.web]
|
[entryPoints.web]
|
||||||
address = ":8000"
|
address = ":8000"
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
[entryPoints.web]
|
[entryPoints.web]
|
||||||
address = ":8000"
|
address = ":8000"
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
[entryPoints.web]
|
[entryPoints.web]
|
||||||
address = ":8000"
|
address = ":8000"
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
[entryPoints.web]
|
[entryPoints.web]
|
||||||
address = ":8000"
|
address = ":8000"
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ fblo6RBxUQ==
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
[global]
|
|
||||||
checkNewVersion = false
|
|
||||||
sendAnonymousUsage = false
|
|
||||||
|
|
||||||
[log]
|
|
||||||
filePath = "traefik.log"
|
|
||||||
level = "ERROR"
|
|
||||||
|
|
||||||
[accessLog]
|
|
||||||
filePath = "access.log"
|
|
||||||
|
|
||||||
[entryPoints]
|
|
||||||
[entryPoints.web]
|
|
||||||
address = ":8000"
|
|
||||||
[entryPoints.api]
|
|
||||||
address = ":7888"
|
|
||||||
|
|
||||||
[api]
|
|
||||||
entryPoint = "api"
|
|
||||||
|
|
||||||
[providers]
|
|
||||||
[providers.file]
|
|
||||||
|
|
||||||
## dynamic configuration ##
|
|
||||||
|
|
||||||
[http.routers]
|
|
||||||
[http.routers.router1]
|
|
||||||
Service = "service1"
|
|
||||||
rule = "Path(`/test1`)"
|
|
||||||
|
|
||||||
[http.services]
|
|
||||||
[http.services.service1]
|
|
||||||
[http.services.service1.loadBalancer]
|
|
||||||
|
|
||||||
[[http.services.service1.loadBalancer.servers]]
|
|
||||||
url = "http://127.0.0.1:8081"
|
|
|
@ -17,6 +17,7 @@
|
||||||
exposedByDefault = false
|
exposedByDefault = false
|
||||||
|
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
[providers.rest]
|
[providers.rest]
|
||||||
|
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
[entryPoints.api]
|
[entryPoints.api]
|
||||||
address = ":8080"
|
address = ":8080"
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
|
|
||||||
[ping]
|
[ping]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
@ -32,5 +32,5 @@
|
||||||
[http.services]
|
[http.services]
|
||||||
[http.services.service.loadBalancer]
|
[http.services.service.loadBalancer]
|
||||||
[[http.services.service.loadBalancer.servers]]
|
[[http.services.service.loadBalancer.servers]]
|
||||||
url = "{{.Server}}"
|
url = "{{ .Server }}"
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
[ping]
|
[ping]
|
||||||
|
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
|
## dynamic configuration ##
|
||||||
|
|
||||||
[http.middlewares]
|
[http.middlewares]
|
||||||
[http.middlewares.authentication.basicAuth]
|
[http.middlewares.authentication.basicAuth]
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
|
## dynamic configuration ##
|
||||||
|
|
||||||
[tcp]
|
[tcp]
|
||||||
[tcp.routers]
|
[tcp.routers]
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
watch = true
|
watch = true
|
||||||
|
|
||||||
[providers.file]
|
[providers.file]
|
||||||
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
samplingServerURL = "http://{{.IP}}:5778/sampling"
|
samplingServerURL = "http://{{.IP}}:5778/sampling"
|
||||||
localAgentHostPort = "{{.IP}}:6831"
|
localAgentHostPort = "{{.IP}}:6831"
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
httpEndpoint = "http://{{.IP}}:9411/api/v1/spans"
|
httpEndpoint = "http://{{.IP}}:9411/api/v1/spans"
|
||||||
debug = true
|
debug = true
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
[api]
|
[api]
|
||||||
|
|
||||||
[providers]
|
[providers.file]
|
||||||
[providers.file]
|
filename = "{{ .SelfFilename }}"
|
||||||
|
|
||||||
## dynamic configuration ##
|
## dynamic configuration ##
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containous/traefik/integration/try"
|
"github.com/containous/traefik/integration/try"
|
||||||
|
@ -25,7 +26,9 @@ func (s *HeadersSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *HeadersSuite) TestCorsResponses(c *check.C) {
|
func (s *HeadersSuite) TestCorsResponses(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/headers/cors.toml"))
|
file := s.adaptFile(c, "fixtures/headers/cors.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
|
|
|
@ -25,7 +25,9 @@ type HTTPSSuite struct{ BaseSuite }
|
||||||
// "snitest.com", which happens to match the CN of 'snitest.com.crt'. The test
|
// "snitest.com", which happens to match the CN of 'snitest.com.crt'. The test
|
||||||
// verifies that traefik presents the correct certificate.
|
// verifies that traefik presents the correct certificate.
|
||||||
func (s *HTTPSSuite) TestWithSNIConfigHandshake(c *check.C) {
|
func (s *HTTPSSuite) TestWithSNIConfigHandshake(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/https_sni.toml"))
|
file := s.adaptFile(c, "fixtures/https/https_sni.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -59,7 +61,9 @@ func (s *HTTPSSuite) TestWithSNIConfigHandshake(c *check.C) {
|
||||||
// SNI hostnames of "snitest.org" and "snitest.com". The test verifies
|
// SNI hostnames of "snitest.org" and "snitest.com". The test verifies
|
||||||
// that traefik routes the requests to the expected backends.
|
// that traefik routes the requests to the expected backends.
|
||||||
func (s *HTTPSSuite) TestWithSNIConfigRoute(c *check.C) {
|
func (s *HTTPSSuite) TestWithSNIConfigRoute(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/https_sni.toml"))
|
file := s.adaptFile(c, "fixtures/https/https_sni.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -113,7 +117,9 @@ func (s *HTTPSSuite) TestWithSNIConfigRoute(c *check.C) {
|
||||||
|
|
||||||
// TestWithTLSOptions verifies that traefik routes the requests with the associated tls options.
|
// TestWithTLSOptions verifies that traefik routes the requests with the associated tls options.
|
||||||
func (s *HTTPSSuite) TestWithTLSOptions(c *check.C) {
|
func (s *HTTPSSuite) TestWithTLSOptions(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/https_tls_options.toml"))
|
file := s.adaptFile(c, "fixtures/https/https_tls_options.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -197,7 +203,9 @@ func (s *HTTPSSuite) TestWithTLSOptions(c *check.C) {
|
||||||
|
|
||||||
// TestWithConflictingTLSOptions checks that routers with same SNI but different TLS options get fallbacked to the default TLS options.
|
// TestWithConflictingTLSOptions checks that routers with same SNI but different TLS options get fallbacked to the default TLS options.
|
||||||
func (s *HTTPSSuite) TestWithConflictingTLSOptions(c *check.C) {
|
func (s *HTTPSSuite) TestWithConflictingTLSOptions(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/https_tls_options.toml"))
|
file := s.adaptFile(c, "fixtures/https/https_tls_options.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -265,7 +273,9 @@ func (s *HTTPSSuite) TestWithConflictingTLSOptions(c *check.C) {
|
||||||
// "snitest.org", which does not match the CN of 'snitest.com.crt'. The test
|
// "snitest.org", which does not match the CN of 'snitest.com.crt'. The test
|
||||||
// verifies that traefik closes the connection.
|
// verifies that traefik closes the connection.
|
||||||
func (s *HTTPSSuite) TestWithSNIStrictNotMatchedRequest(c *check.C) {
|
func (s *HTTPSSuite) TestWithSNIStrictNotMatchedRequest(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/https_sni_strict.toml"))
|
file := s.adaptFile(c, "fixtures/https/https_sni_strict.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -289,7 +299,9 @@ func (s *HTTPSSuite) TestWithSNIStrictNotMatchedRequest(c *check.C) {
|
||||||
// "snitest.org", which does not match the CN of 'snitest.com.crt'. The test
|
// "snitest.org", which does not match the CN of 'snitest.com.crt'. The test
|
||||||
// verifies that traefik returns the default certificate.
|
// verifies that traefik returns the default certificate.
|
||||||
func (s *HTTPSSuite) TestWithDefaultCertificate(c *check.C) {
|
func (s *HTTPSSuite) TestWithDefaultCertificate(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/https_sni_default_cert.toml"))
|
file := s.adaptFile(c, "fixtures/https/https_sni_default_cert.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -323,7 +335,9 @@ func (s *HTTPSSuite) TestWithDefaultCertificate(c *check.C) {
|
||||||
// which does not match the CN of 'snitest.com.crt'. The test
|
// which does not match the CN of 'snitest.com.crt'. The test
|
||||||
// verifies that traefik returns the default certificate.
|
// verifies that traefik returns the default certificate.
|
||||||
func (s *HTTPSSuite) TestWithDefaultCertificateNoSNI(c *check.C) {
|
func (s *HTTPSSuite) TestWithDefaultCertificateNoSNI(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/https_sni_default_cert.toml"))
|
file := s.adaptFile(c, "fixtures/https/https_sni_default_cert.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -357,7 +371,9 @@ func (s *HTTPSSuite) TestWithDefaultCertificateNoSNI(c *check.C) {
|
||||||
// 'wildcard.snitest.com.crt', and `www.snitest.com.crt`. The test
|
// 'wildcard.snitest.com.crt', and `www.snitest.com.crt`. The test
|
||||||
// verifies that traefik returns the non-wildcard certificate.
|
// verifies that traefik returns the non-wildcard certificate.
|
||||||
func (s *HTTPSSuite) TestWithOverlappingStaticCertificate(c *check.C) {
|
func (s *HTTPSSuite) TestWithOverlappingStaticCertificate(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/https_sni_default_cert.toml"))
|
file := s.adaptFile(c, "fixtures/https/https_sni_default_cert.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -392,7 +408,9 @@ func (s *HTTPSSuite) TestWithOverlappingStaticCertificate(c *check.C) {
|
||||||
// 'wildcard.snitest.com.crt', and `www.snitest.com.crt`. The test
|
// 'wildcard.snitest.com.crt', and `www.snitest.com.crt`. The test
|
||||||
// verifies that traefik returns the non-wildcard certificate.
|
// verifies that traefik returns the non-wildcard certificate.
|
||||||
func (s *HTTPSSuite) TestWithOverlappingDynamicCertificate(c *check.C) {
|
func (s *HTTPSSuite) TestWithOverlappingDynamicCertificate(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/dynamic_https_sni_default_cert.toml"))
|
file := s.adaptFile(c, "fixtures/https/dynamic_https_sni_default_cert.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -425,7 +443,9 @@ func (s *HTTPSSuite) TestWithOverlappingDynamicCertificate(c *check.C) {
|
||||||
// TestWithClientCertificateAuthentication
|
// TestWithClientCertificateAuthentication
|
||||||
// The client can send a certificate signed by a CA trusted by the server but it's optional
|
// The client can send a certificate signed by a CA trusted by the server but it's optional
|
||||||
func (s *HTTPSSuite) TestWithClientCertificateAuthentication(c *check.C) {
|
func (s *HTTPSSuite) TestWithClientCertificateAuthentication(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/clientca/https_1ca1config.toml"))
|
file := s.adaptFile(c, "fixtures/https/clientca/https_1ca1config.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -481,7 +501,9 @@ func (s *HTTPSSuite) TestWithClientCertificateAuthentication(c *check.C) {
|
||||||
// TestWithClientCertificateAuthentication
|
// TestWithClientCertificateAuthentication
|
||||||
// Use two CA:s and test that clients with client signed by either of them can connect
|
// Use two CA:s and test that clients with client signed by either of them can connect
|
||||||
func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipleCAs(c *check.C) {
|
func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipleCAs(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/clientca/https_2ca1config.toml"))
|
file := s.adaptFile(c, "fixtures/https/clientca/https_2ca1config.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -542,7 +564,9 @@ func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipleCAs(c *check
|
||||||
// TestWithClientCertificateAuthentication
|
// TestWithClientCertificateAuthentication
|
||||||
// Use two CA:s in two different files and test that clients with client signed by either of them can connect
|
// Use two CA:s in two different files and test that clients with client signed by either of them can connect
|
||||||
func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipleCAsMultipleFiles(c *check.C) {
|
func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipleCAsMultipleFiles(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/clientca/https_2ca2config.toml"))
|
file := s.adaptFile(c, "fixtures/https/clientca/https_2ca2config.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -777,7 +801,7 @@ func (s *HTTPSSuite) TestWithSNIDynamicConfigRouteWithChange(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// Change certificates configuration file content
|
// Change certificates configuration file content
|
||||||
modifyCertificateConfFileContent(c, tr1.TLSClientConfig.ServerName, dynamicConfFileName, "https")
|
modifyCertificateConfFileContent(c, tr1.TLSClientConfig.ServerName, dynamicConfFileName)
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodGet, "https://127.0.0.1:4443/", nil)
|
req, err := http.NewRequest(http.MethodGet, "https://127.0.0.1:4443/", nil)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -846,14 +870,14 @@ func (s *HTTPSSuite) TestWithSNIDynamicConfigRouteWithTlsConfigurationDeletion(c
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// Change certificates configuration file content
|
// Change certificates configuration file content
|
||||||
modifyCertificateConfFileContent(c, "", dynamicConfFileName, "https02")
|
modifyCertificateConfFileContent(c, "", dynamicConfFileName)
|
||||||
|
|
||||||
err = try.RequestWithTransport(req, 30*time.Second, tr2, try.HasCn("TRAEFIK DEFAULT CERT"), try.StatusCodeIs(http.StatusNotFound))
|
err = try.RequestWithTransport(req, 30*time.Second, tr2, try.HasCn("TRAEFIK DEFAULT CERT"), try.StatusCodeIs(http.StatusNotFound))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// modifyCertificateConfFileContent replaces the content of a HTTPS configuration file.
|
// modifyCertificateConfFileContent replaces the content of a HTTPS configuration file.
|
||||||
func modifyCertificateConfFileContent(c *check.C, certFileName, confFileName, entryPoint string) {
|
func modifyCertificateConfFileContent(c *check.C, certFileName, confFileName string) {
|
||||||
file, err := os.OpenFile("./"+confFileName, os.O_WRONLY, os.ModeExclusive)
|
file, err := os.OpenFile("./"+confFileName, os.O_WRONLY, os.ModeExclusive)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -884,8 +908,10 @@ func modifyCertificateConfFileContent(c *check.C, certFileName, confFileName, en
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *HTTPSSuite) TestEntrypointHttpsRedirectAndPathModification(c *check.C) {
|
func (s *HTTPSSuite) TestEntryPointHttpsRedirectAndPathModification(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/https_redirect.toml"))
|
file := s.adaptFile(c, "fixtures/https/https_redirect.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -986,7 +1012,9 @@ func (s *HTTPSSuite) TestEntrypointHttpsRedirectAndPathModification(c *check.C)
|
||||||
// "bar.www.snitest.com", which matches the DNS SAN of '*.WWW.SNITEST.COM'. The test
|
// "bar.www.snitest.com", which matches the DNS SAN of '*.WWW.SNITEST.COM'. The test
|
||||||
// verifies that traefik presents the correct certificate.
|
// verifies that traefik presents the correct certificate.
|
||||||
func (s *HTTPSSuite) TestWithSNIDynamicCaseInsensitive(c *check.C) {
|
func (s *HTTPSSuite) TestWithSNIDynamicCaseInsensitive(c *check.C) {
|
||||||
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/https_sni_case_insensitive_dynamic.toml"))
|
file := s.adaptFile(c, "fixtures/https/https_sni_case_insensitive_dynamic.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/containous/traefik/pkg/log"
|
"github.com/containous/traefik/pkg/log"
|
||||||
|
"github.com/fatih/structs"
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
compose "github.com/libkermit/compose/check"
|
compose "github.com/libkermit/compose/check"
|
||||||
checker "github.com/vdemeester/shakers"
|
checker "github.com/vdemeester/shakers"
|
||||||
|
@ -150,7 +151,10 @@ func (s *BaseSuite) adaptFile(c *check.C, path string, tempObjects interface{})
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer tmpFile.Close()
|
defer tmpFile.Close()
|
||||||
|
|
||||||
err = tmpl.ExecuteTemplate(tmpFile, prefix, tempObjects)
|
model := structs.Map(tempObjects)
|
||||||
|
model["SelfFilename"] = tmpFile.Name()
|
||||||
|
|
||||||
|
err = tmpl.ExecuteTemplate(tmpFile, prefix, model)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
err = tmpFile.Sync()
|
err = tmpFile.Sync()
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,7 @@ func (s *SimpleSuite) TestRequestAcceptGraceTimeout(c *check.C) {
|
||||||
Server string
|
Server string
|
||||||
}{whoami})
|
}{whoami})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
|
|
||||||
cmd, display := s.traefikCmd(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
defer display(c)
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
|
@ -223,7 +224,9 @@ func (s *SimpleSuite) TestNoAuthOnPing(c *check.C) {
|
||||||
s.createComposeProject(c, "base")
|
s.createComposeProject(c, "base")
|
||||||
s.composeProject.Start(c)
|
s.composeProject.Start(c)
|
||||||
|
|
||||||
cmd, output := s.traefikCmd(withConfigFile("./fixtures/simple_auth.toml"))
|
file := s.adaptFile(c, "./fixtures/simple_auth.toml", struct{}{})
|
||||||
|
defer os.Remove(file)
|
||||||
|
cmd, output := s.traefikCmd(withConfigFile(file))
|
||||||
defer output(c)
|
defer output(c)
|
||||||
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
|
@ -237,7 +240,7 @@ func (s *SimpleSuite) TestNoAuthOnPing(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SimpleSuite) TestDefaultEntrypointHTTP(c *check.C) {
|
func (s *SimpleSuite) TestDefaultEntryPointHTTP(c *check.C) {
|
||||||
s.createComposeProject(c, "base")
|
s.createComposeProject(c, "base")
|
||||||
s.composeProject.Start(c)
|
s.composeProject.Start(c)
|
||||||
|
|
||||||
|
@ -255,7 +258,7 @@ func (s *SimpleSuite) TestDefaultEntrypointHTTP(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SimpleSuite) TestWithUnexistingEntrypoint(c *check.C) {
|
func (s *SimpleSuite) TestWithNonExistingEntryPoint(c *check.C) {
|
||||||
s.createComposeProject(c, "base")
|
s.createComposeProject(c, "base")
|
||||||
s.composeProject.Start(c)
|
s.composeProject.Start(c)
|
||||||
|
|
||||||
|
@ -273,7 +276,7 @@ func (s *SimpleSuite) TestWithUnexistingEntrypoint(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SimpleSuite) TestMetricsPrometheusDefaultEntrypoint(c *check.C) {
|
func (s *SimpleSuite) TestMetricsPrometheusDefaultEntryPoint(c *check.C) {
|
||||||
s.createComposeProject(c, "base")
|
s.createComposeProject(c, "base")
|
||||||
s.composeProject.Start(c)
|
s.composeProject.Start(c)
|
||||||
|
|
||||||
|
@ -419,7 +422,7 @@ func (s *SimpleSuite) TestXForwardedHeaders(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SimpleSuite) TestMultiprovider(c *check.C) {
|
func (s *SimpleSuite) TestMultiProvider(c *check.C) {
|
||||||
s.createComposeProject(c, "base")
|
s.createComposeProject(c, "base")
|
||||||
s.composeProject.Start(c)
|
s.composeProject.Start(c)
|
||||||
|
|
||||||
|
@ -453,10 +456,10 @@ func (s *SimpleSuite) TestMultiprovider(c *check.C) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
json, err := json.Marshal(config)
|
jsonContent, err := json.Marshal(config)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
request, err := http.NewRequest(http.MethodPut, "http://127.0.0.1:8080/api/providers/rest", bytes.NewReader(json))
|
request, err := http.NewRequest(http.MethodPut, "http://127.0.0.1:8080/api/providers/rest", bytes.NewReader(jsonContent))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
response, err := http.DefaultClient.Do(request)
|
response, err := http.DefaultClient.Do(request)
|
||||||
|
|
|
@ -149,7 +149,6 @@ func TestDo_globalConfiguration(t *testing.T) {
|
||||||
Watch: true,
|
Watch: true,
|
||||||
Filename: "file Filename",
|
Filename: "file Filename",
|
||||||
DebugLogGeneratedTemplate: true,
|
DebugLogGeneratedTemplate: true,
|
||||||
TraefikFile: "",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Providers.Docker = &docker.Provider{
|
config.Providers.Docker = &docker.Provider{
|
||||||
|
|
|
@ -5,17 +5,3 @@ type ResourceLoader interface {
|
||||||
// Load populates cmd.Configuration, optionally using args to do so.
|
// Load populates cmd.Configuration, optionally using args to do so.
|
||||||
Load(args []string, cmd *Command) (bool, error)
|
Load(args []string, cmd *Command) (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type filenameGetter interface {
|
|
||||||
GetFilename() string
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetConfigFile returns the configuration file corresponding to the first configuration file loader found in ResourceLoader, if any.
|
|
||||||
func GetConfigFile(loaders []ResourceLoader) string {
|
|
||||||
for _, loader := range loaders {
|
|
||||||
if v, ok := loader.(filenameGetter); ok {
|
|
||||||
return v.GetFilename()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
watch = true
|
watch = true
|
||||||
filename = "foobar"
|
filename = "foobar"
|
||||||
debugLogGeneratedTemplate = true
|
debugLogGeneratedTemplate = true
|
||||||
traefikFile = "foobar"
|
|
||||||
[providers.marathon]
|
[providers.marathon]
|
||||||
constraints = "foobar"
|
constraints = "foobar"
|
||||||
trace = true
|
trace = true
|
||||||
|
|
|
@ -192,7 +192,6 @@ func Test_decodeFileToNode_Toml(t *testing.T) {
|
||||||
{Name: "debugLogGeneratedTemplate", Value: "true"},
|
{Name: "debugLogGeneratedTemplate", Value: "true"},
|
||||||
{Name: "directory", Value: "foobar"},
|
{Name: "directory", Value: "foobar"},
|
||||||
{Name: "filename", Value: "foobar"},
|
{Name: "filename", Value: "foobar"},
|
||||||
{Name: "traefikFile", Value: "foobar"},
|
|
||||||
{Name: "watch", Value: "true"}}},
|
{Name: "watch", Value: "true"}}},
|
||||||
{Name: "kubernetesCRD",
|
{Name: "kubernetesCRD",
|
||||||
Children: []*parser.Node{
|
Children: []*parser.Node{
|
||||||
|
@ -435,7 +434,6 @@ func Test_decodeFileToNode_Yaml(t *testing.T) {
|
||||||
{Name: "debugLogGeneratedTemplate", Value: "true"},
|
{Name: "debugLogGeneratedTemplate", Value: "true"},
|
||||||
{Name: "directory", Value: "foobar"},
|
{Name: "directory", Value: "foobar"},
|
||||||
{Name: "filename", Value: "foobar"},
|
{Name: "filename", Value: "foobar"},
|
||||||
{Name: "traefikFile", Value: "foobar"},
|
|
||||||
{Name: "watch", Value: "true"}}},
|
{Name: "watch", Value: "true"}}},
|
||||||
{Name: "kubernetesCRD",
|
{Name: "kubernetesCRD",
|
||||||
Children: []*parser.Node{
|
Children: []*parser.Node{
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
watch = true
|
watch = true
|
||||||
filename = "foobar"
|
filename = "foobar"
|
||||||
debugLogGeneratedTemplate = true
|
debugLogGeneratedTemplate = true
|
||||||
traefikFile = "foobar"
|
|
||||||
[providers.marathon]
|
[providers.marathon]
|
||||||
constraints = "foobar"
|
constraints = "foobar"
|
||||||
trace = true
|
trace = true
|
||||||
|
|
|
@ -55,7 +55,6 @@ providers:
|
||||||
watch: true
|
watch: true
|
||||||
filename: foobar
|
filename: foobar
|
||||||
debugLogGeneratedTemplate: true
|
debugLogGeneratedTemplate: true
|
||||||
traefikFile: foobar
|
|
||||||
marathon:
|
marathon:
|
||||||
constraints: foobar
|
constraints: foobar
|
||||||
trace: true
|
trace: true
|
||||||
|
|
|
@ -149,7 +149,7 @@ func (t *Tracing) SetDefaults() {
|
||||||
type Providers struct {
|
type Providers struct {
|
||||||
ProvidersThrottleDuration types.Duration `description:"Backends throttle duration: minimum duration between 2 events from providers before applying a new configuration. It avoids unnecessary reloads if multiples events are sent in a short amount of time." json:"providersThrottleDuration,omitempty" toml:"providersThrottleDuration,omitempty" yaml:"providersThrottleDuration,omitempty" export:"true"`
|
ProvidersThrottleDuration types.Duration `description:"Backends throttle duration: minimum duration between 2 events from providers before applying a new configuration. It avoids unnecessary reloads if multiples events are sent in a short amount of time." json:"providersThrottleDuration,omitempty" toml:"providersThrottleDuration,omitempty" yaml:"providersThrottleDuration,omitempty" export:"true"`
|
||||||
Docker *docker.Provider `description:"Enable Docker backend with default settings." json:"docker,omitempty" toml:"docker,omitempty" yaml:"docker,omitempty" export:"true" label:"allowEmpty"`
|
Docker *docker.Provider `description:"Enable Docker backend with default settings." json:"docker,omitempty" toml:"docker,omitempty" yaml:"docker,omitempty" export:"true" label:"allowEmpty"`
|
||||||
File *file.Provider `description:"Enable File backend with default settings." json:"file,omitempty" toml:"file,omitempty" yaml:"file,omitempty" export:"true" label:"allowEmpty"`
|
File *file.Provider `description:"Enable File backend with default settings." json:"file,omitempty" toml:"file,omitempty" yaml:"file,omitempty" export:"true"`
|
||||||
Marathon *marathon.Provider `description:"Enable Marathon backend with default settings." json:"marathon,omitempty" toml:"marathon,omitempty" yaml:"marathon,omitempty" export:"true" label:"allowEmpty"`
|
Marathon *marathon.Provider `description:"Enable Marathon backend with default settings." json:"marathon,omitempty" toml:"marathon,omitempty" yaml:"marathon,omitempty" export:"true" label:"allowEmpty"`
|
||||||
KubernetesIngress *ingress.Provider `description:"Enable Kubernetes backend with default settings." json:"kubernetesIngress,omitempty" toml:"kubernetesIngress,omitempty" yaml:"kubernetesIngress,omitempty" export:"true" label:"allowEmpty"`
|
KubernetesIngress *ingress.Provider `description:"Enable Kubernetes backend with default settings." json:"kubernetesIngress,omitempty" toml:"kubernetesIngress,omitempty" yaml:"kubernetesIngress,omitempty" export:"true" label:"allowEmpty"`
|
||||||
KubernetesCRD *crd.Provider `description:"Enable Kubernetes backend with default settings." json:"kubernetesCRD,omitempty" toml:"kubernetesCRD,omitempty" yaml:"kubernetesCRD,omitempty" export:"true" label:"allowEmpty"`
|
KubernetesCRD *crd.Provider `description:"Enable Kubernetes backend with default settings." json:"kubernetesCRD,omitempty" toml:"kubernetesCRD,omitempty" yaml:"kubernetesCRD,omitempty" export:"true" label:"allowEmpty"`
|
||||||
|
@ -159,7 +159,7 @@ type Providers struct {
|
||||||
|
|
||||||
// SetEffectiveConfiguration adds missing configuration parameters derived from existing ones.
|
// SetEffectiveConfiguration adds missing configuration parameters derived from existing ones.
|
||||||
// It also takes care of maintaining backwards compatibility.
|
// It also takes care of maintaining backwards compatibility.
|
||||||
func (c *Configuration) SetEffectiveConfiguration(configFile string) {
|
func (c *Configuration) SetEffectiveConfiguration() {
|
||||||
if len(c.EntryPoints) == 0 {
|
if len(c.EntryPoints) == 0 {
|
||||||
ep := &EntryPoint{Address: ":80"}
|
ep := &EntryPoint{Address: ":80"}
|
||||||
ep.SetDefaults()
|
ep.SetDefaults()
|
||||||
|
@ -185,10 +185,6 @@ func (c *Configuration) SetEffectiveConfiguration(configFile string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Providers.File != nil {
|
|
||||||
c.Providers.File.TraefikFile = configFile
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.Providers.Rancher != nil {
|
if c.Providers.Rancher != nil {
|
||||||
if c.Providers.Rancher.RefreshSeconds <= 0 {
|
if c.Providers.Rancher.RefreshSeconds <= 0 {
|
||||||
c.Providers.Rancher.RefreshSeconds = 15
|
c.Providers.Rancher.RefreshSeconds = 15
|
||||||
|
|
|
@ -32,7 +32,6 @@ type Provider struct {
|
||||||
Watch bool `description:"Watch provider." json:"watch,omitempty" toml:"watch,omitempty" yaml:"watch,omitempty" export:"true"`
|
Watch bool `description:"Watch provider." json:"watch,omitempty" toml:"watch,omitempty" yaml:"watch,omitempty" export:"true"`
|
||||||
Filename string `description:"Override default configuration template. For advanced users :)" json:"filename,omitempty" toml:"filename,omitempty" yaml:"filename,omitempty" export:"true"`
|
Filename string `description:"Override default configuration template. For advanced users :)" json:"filename,omitempty" toml:"filename,omitempty" yaml:"filename,omitempty" export:"true"`
|
||||||
DebugLogGeneratedTemplate bool `description:"Enable debug logging of generated configuration template." json:"debugLogGeneratedTemplate,omitempty" toml:"debugLogGeneratedTemplate,omitempty" yaml:"debugLogGeneratedTemplate,omitempty" export:"true"`
|
DebugLogGeneratedTemplate bool `description:"Enable debug logging of generated configuration template." json:"debugLogGeneratedTemplate,omitempty" toml:"debugLogGeneratedTemplate,omitempty" yaml:"debugLogGeneratedTemplate,omitempty" export:"true"`
|
||||||
TraefikFile string `description:"-" json:"traefikFile,omitempty" toml:"-" yaml:"-"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDefaults sets the default values.
|
// SetDefaults sets the default values.
|
||||||
|
@ -64,7 +63,7 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
|
||||||
case len(p.Filename) > 0:
|
case len(p.Filename) > 0:
|
||||||
watchItem = filepath.Dir(p.Filename)
|
watchItem = filepath.Dir(p.Filename)
|
||||||
default:
|
default:
|
||||||
watchItem = filepath.Dir(p.TraefikFile)
|
return errors.New("error using file configuration provider, neither filename or directory defined")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := p.addWatcher(pool, watchItem, configurationChan, p.watcherCallback); err != nil {
|
if err := p.addWatcher(pool, watchItem, configurationChan, p.watcherCallback); err != nil {
|
||||||
|
@ -89,11 +88,7 @@ func (p *Provider) BuildConfiguration() (*dynamic.Configuration, error) {
|
||||||
return p.loadFileConfig(p.Filename, true)
|
return p.loadFileConfig(p.Filename, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(p.TraefikFile) > 0 {
|
return nil, errors.New("error using file configuration provider, neither filename or directory defined")
|
||||||
return p.loadFileConfig(p.TraefikFile, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, errors.New("error using file configuration backend, no filename defined")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provider) addWatcher(pool *safe.Pool, directory string, configurationChan chan<- dynamic.Message, callback func(chan<- dynamic.Message, fsnotify.Event)) error {
|
func (p *Provider) addWatcher(pool *safe.Pool, directory string, configurationChan chan<- dynamic.Message, callback func(chan<- dynamic.Message, fsnotify.Event)) error {
|
||||||
|
@ -116,15 +111,8 @@ func (p *Provider) addWatcher(pool *safe.Pool, directory string, configurationCh
|
||||||
return
|
return
|
||||||
case evt := <-watcher.Events:
|
case evt := <-watcher.Events:
|
||||||
if p.Directory == "" {
|
if p.Directory == "" {
|
||||||
var filename string
|
|
||||||
if len(p.Filename) > 0 {
|
|
||||||
filename = p.Filename
|
|
||||||
} else {
|
|
||||||
filename = p.TraefikFile
|
|
||||||
}
|
|
||||||
|
|
||||||
_, evtFileName := filepath.Split(evt.Name)
|
_, evtFileName := filepath.Split(evt.Name)
|
||||||
_, confFileName := filepath.Split(filename)
|
_, confFileName := filepath.Split(p.Filename)
|
||||||
if evtFileName == confFileName {
|
if evtFileName == confFileName {
|
||||||
callback(configurationChan, evt)
|
callback(configurationChan, evt)
|
||||||
}
|
}
|
||||||
|
@ -140,11 +128,9 @@ func (p *Provider) addWatcher(pool *safe.Pool, directory string, configurationCh
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provider) watcherCallback(configurationChan chan<- dynamic.Message, event fsnotify.Event) {
|
func (p *Provider) watcherCallback(configurationChan chan<- dynamic.Message, event fsnotify.Event) {
|
||||||
watchItem := p.TraefikFile
|
watchItem := p.Filename
|
||||||
if len(p.Directory) > 0 {
|
if len(p.Directory) > 0 {
|
||||||
watchItem = p.Directory
|
watchItem = p.Directory
|
||||||
} else if len(p.Filename) > 0 {
|
|
||||||
watchItem = p.Filename
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger := log.WithoutContext().WithField(log.ProviderName, providerName)
|
logger := log.WithoutContext().WithField(log.ProviderName, providerName)
|
||||||
|
|
|
@ -20,7 +20,6 @@ type ProvideTestCase struct {
|
||||||
desc string
|
desc string
|
||||||
directoryPaths []string
|
directoryPaths []string
|
||||||
filePath string
|
filePath string
|
||||||
traefikFilePath string
|
|
||||||
expectedNumRouter int
|
expectedNumRouter int
|
||||||
expectedNumService int
|
expectedNumService int
|
||||||
expectedNumTLSConf int
|
expectedNumTLSConf int
|
||||||
|
@ -131,11 +130,6 @@ func TestProvideWithWatch(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(test.traefikFilePath) > 0 {
|
|
||||||
err := copyFile(test.traefikFilePath, provider.TraefikFile)
|
|
||||||
require.NoError(t, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(test.directoryPaths) > 0 {
|
if len(test.directoryPaths) > 0 {
|
||||||
for i, filePath := range test.directoryPaths {
|
for i, filePath := range test.directoryPaths {
|
||||||
err := copyFile(filePath, filepath.Join(provider.Directory, strconv.Itoa(i)+filepath.Ext(filePath)))
|
err := copyFile(filePath, filepath.Join(provider.Directory, strconv.Itoa(i)+filepath.Ext(filePath)))
|
||||||
|
@ -181,36 +175,6 @@ func getTestCases() []ProvideTestCase {
|
||||||
expectedNumService: 6,
|
expectedNumService: 6,
|
||||||
expectedNumTLSConf: 5,
|
expectedNumTLSConf: 5,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
desc: "simple file and a traefik file",
|
|
||||||
filePath: "./fixtures/toml/simple_file_02.toml",
|
|
||||||
traefikFilePath: "./fixtures/toml/simple_traefik_file_01.toml",
|
|
||||||
expectedNumRouter: 4,
|
|
||||||
expectedNumService: 8,
|
|
||||||
expectedNumTLSConf: 4,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
desc: "simple file and a traefik file yaml",
|
|
||||||
filePath: "./fixtures/yaml/simple_file_02.yml",
|
|
||||||
traefikFilePath: "./fixtures/yaml/simple_traefik_file_01.yml",
|
|
||||||
expectedNumRouter: 4,
|
|
||||||
expectedNumService: 8,
|
|
||||||
expectedNumTLSConf: 4,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
desc: "simple traefik file",
|
|
||||||
traefikFilePath: "./fixtures/toml/simple_traefik_file_02.toml",
|
|
||||||
expectedNumRouter: 2,
|
|
||||||
expectedNumService: 3,
|
|
||||||
expectedNumTLSConf: 4,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
desc: "simple traefik file yaml",
|
|
||||||
traefikFilePath: "./fixtures/yaml/simple_traefik_file_02.yml",
|
|
||||||
expectedNumRouter: 2,
|
|
||||||
expectedNumService: 3,
|
|
||||||
expectedNumTLSConf: 4,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
desc: "template file",
|
desc: "template file",
|
||||||
filePath: "./fixtures/toml/template_file.toml",
|
filePath: "./fixtures/toml/template_file.toml",
|
||||||
|
@ -221,13 +185,6 @@ func getTestCases() []ProvideTestCase {
|
||||||
filePath: "./fixtures/yaml/template_file.yml",
|
filePath: "./fixtures/yaml/template_file.yml",
|
||||||
expectedNumRouter: 20,
|
expectedNumRouter: 20,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
desc: "simple traefik file with templating",
|
|
||||||
traefikFilePath: "./fixtures/toml/simple_traefik_file_with_templating.toml",
|
|
||||||
expectedNumRouter: 2,
|
|
||||||
expectedNumService: 3,
|
|
||||||
expectedNumTLSConf: 4,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
desc: "simple directory",
|
desc: "simple directory",
|
||||||
directoryPaths: []string{
|
directoryPaths: []string{
|
||||||
|
@ -304,21 +261,6 @@ func createProvider(t *testing.T, test ProvideTestCase, watch bool) (*Provider,
|
||||||
provider.Filename = file.Name()
|
provider.Filename = file.Name()
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(test.traefikFilePath) > 0 {
|
|
||||||
var file *os.File
|
|
||||||
if watch {
|
|
||||||
var err error
|
|
||||||
file, err = ioutil.TempFile(tempDir, "temp*"+filepath.Ext(test.traefikFilePath))
|
|
||||||
require.NoError(t, err)
|
|
||||||
} else {
|
|
||||||
var err error
|
|
||||||
file, err = createTempFile(test.traefikFilePath, tempDir)
|
|
||||||
require.NoError(t, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
provider.TraefikFile = file.Name()
|
|
||||||
}
|
|
||||||
|
|
||||||
return provider, func() {
|
return provider, func() {
|
||||||
os.RemoveAll(tempDir)
|
os.RemoveAll(tempDir)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
[log]
|
|
||||||
level = "DEBUG"
|
|
|
@ -1,44 +0,0 @@
|
||||||
[providers.file]
|
|
||||||
|
|
||||||
## dynamic configuration ##
|
|
||||||
|
|
||||||
[http.routers]
|
|
||||||
|
|
||||||
[http.routers."router1"]
|
|
||||||
service = "application-1"
|
|
||||||
|
|
||||||
[http.routers."router2"]
|
|
||||||
service = "application-2"
|
|
||||||
|
|
||||||
|
|
||||||
[http.services]
|
|
||||||
|
|
||||||
[http.services.application-1.loadBalancer]
|
|
||||||
[[http.services.application-1.loadBalancer.servers]]
|
|
||||||
url = "http://172.17.0.1:80"
|
|
||||||
|
|
||||||
[http.services.application-2.loadBalancer]
|
|
||||||
[[http.services.application-2.loadBalancer.servers]]
|
|
||||||
url = "http://172.17.0.2:80"
|
|
||||||
|
|
||||||
[http.services.application-3.loadBalancer]
|
|
||||||
[[http.services.application-3.loadBalancer.servers]]
|
|
||||||
url = "http://172.17.0.3:80"
|
|
||||||
|
|
||||||
[tls]
|
|
||||||
|
|
||||||
[[tls.certificates]]
|
|
||||||
certFile = "integration/fixtures/https/snitest1.com.cert"
|
|
||||||
keyFile = "integration/fixtures/https/snitest1.com.key"
|
|
||||||
|
|
||||||
[[tls.certificates]]
|
|
||||||
certFile = "integration/fixtures/https/snitest2.com.cert"
|
|
||||||
keyFile = "integration/fixtures/https/snitest2.com.key"
|
|
||||||
|
|
||||||
[[tls.certificates]]
|
|
||||||
certFile = "integration/fixtures/https/snitest3.com.cert"
|
|
||||||
keyFile = "integration/fixtures/https/snitest3.com.key"
|
|
||||||
|
|
||||||
[[tls.certificates]]
|
|
||||||
certFile = "integration/fixtures/https/snitest4.com.cert"
|
|
||||||
keyFile = "integration/fixtures/https/snitest4.com.key"
|
|
|
@ -1,45 +0,0 @@
|
||||||
temp="{{ getTag \"test\" }}"
|
|
||||||
|
|
||||||
[providers.file]
|
|
||||||
|
|
||||||
## dynamic configuration ##
|
|
||||||
|
|
||||||
[http.routers]
|
|
||||||
|
|
||||||
[http.routers."router1"]
|
|
||||||
service = "application-1"
|
|
||||||
|
|
||||||
[http.routers."router2"]
|
|
||||||
service = "application-2"
|
|
||||||
|
|
||||||
[http.services]
|
|
||||||
|
|
||||||
[http.services.application-1.loadBalancer]
|
|
||||||
[[http.services.application-1.loadBalancer.servers]]
|
|
||||||
url = "http://172.17.0.1:80"
|
|
||||||
|
|
||||||
[http.services.application-2.loadBalancer]
|
|
||||||
[[http.services.application-2.loadBalancer.servers]]
|
|
||||||
url = "http://172.17.0.2:80"
|
|
||||||
|
|
||||||
[http.services.application-3.loadBalancer]
|
|
||||||
[[http.services.application-3.loadBalancer.servers]]
|
|
||||||
url = "http://172.17.0.3:80"
|
|
||||||
|
|
||||||
[tls]
|
|
||||||
|
|
||||||
[[tls.certificates]]
|
|
||||||
certFile = "integration/fixtures/https/snitest1.com.cert"
|
|
||||||
keyFile = "integration/fixtures/https/snitest1.com.key"
|
|
||||||
|
|
||||||
[[tls.certificates]]
|
|
||||||
certFile = "integration/fixtures/https/snitest2.com.cert"
|
|
||||||
keyFile = "integration/fixtures/https/snitest2.com.key"
|
|
||||||
|
|
||||||
[[tls.certificates]]
|
|
||||||
certFile = "integration/fixtures/https/snitest3.com.cert"
|
|
||||||
keyFile = "integration/fixtures/https/snitest3.com.key"
|
|
||||||
|
|
||||||
[[tls.certificates]]
|
|
||||||
certFile = "integration/fixtures/https/snitest4.com.cert"
|
|
||||||
keyFile = "integration/fixtures/https/snitest4.com.key"
|
|
|
@ -1,2 +0,0 @@
|
||||||
log:
|
|
||||||
level: DEBUG
|
|
|
@ -1,32 +0,0 @@
|
||||||
providers:
|
|
||||||
file: {}
|
|
||||||
http:
|
|
||||||
routers:
|
|
||||||
router1:
|
|
||||||
service: application-1
|
|
||||||
router2:
|
|
||||||
service: application-2
|
|
||||||
services:
|
|
||||||
application-1:
|
|
||||||
loadBalancer:
|
|
||||||
servers:
|
|
||||||
- url: 'http://172.17.0.1:80'
|
|
||||||
application-2:
|
|
||||||
loadBalancer:
|
|
||||||
servers:
|
|
||||||
- url: 'http://172.17.0.2:80'
|
|
||||||
application-3:
|
|
||||||
loadBalancer:
|
|
||||||
servers:
|
|
||||||
- url: 'http://172.17.0.3:80'
|
|
||||||
|
|
||||||
tls:
|
|
||||||
certificates:
|
|
||||||
- certFile: integration/fixtures/https/snitest1.com.cert
|
|
||||||
keyFile: integration/fixtures/https/snitest1.com.key
|
|
||||||
- certFile: integration/fixtures/https/snitest2.com.cert
|
|
||||||
keyFile: integration/fixtures/https/snitest2.com.key
|
|
||||||
- certFile: integration/fixtures/https/snitest3.com.cert
|
|
||||||
keyFile: integration/fixtures/https/snitest3.com.key
|
|
||||||
- certFile: integration/fixtures/https/snitest4.com.cert
|
|
||||||
keyFile: integration/fixtures/https/snitest4.com.key
|
|
Loading…
Reference in a new issue