Skip to content

Commit

Permalink
Merge branch 'v1.7.2' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Oct 5, 2018
2 parents 1431ac5 + a9deeb3 commit 05f052b
Show file tree
Hide file tree
Showing 36 changed files with 694 additions and 174 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Change Log

## [v1.7.2](https://github.com/containous/traefik/tree/v1.7.2) (2018-10-04)
[All Commits](https://github.com/containous/traefik/compare/v1.7.1...v1.7.2)

**Bug fixes:**
- **[acme,cluster,kv]** TLS, ACME, cluster and several entrypoints. ([#3962](https://github.com/containous/traefik/pull/3962) by [ldez](https://github.com/ldez))
- **[cluster,kv]** Correctly initialize kv store if storage key missing ([#3958](https://github.com/containous/traefik/pull/3958) by [jfrabaute](https://github.com/jfrabaute))
- **[cluster,kv]** Return an error if kv store CA cert is invalid ([#3956](https://github.com/containous/traefik/pull/3956) by [jfrabaute](https://github.com/jfrabaute))
- **[file]** Do not Errorf during file watcher verification test loop. ([#3938](https://github.com/containous/traefik/pull/3938) by [timoreimann](https://github.com/timoreimann))
- **[k8s]** Add Template-ability check to Kubernetes API Fields ([#3964](https://github.com/containous/traefik/pull/3964) by [dtomcej](https://github.com/dtomcej))
- **[logs]** Colored logs on windows. ([#3966](https://github.com/containous/traefik/pull/3966) by [ldez](https://github.com/ldez))
- **[middleware]** Whitelist log for deprecated configuration. ([#3963](https://github.com/containous/traefik/pull/3963) by [ldez](https://github.com/ldez))
- **[middleware]** Trimming whitespace in XFF for IP whitelisting ([#3971](https://github.com/containous/traefik/pull/3971) by [olmoser](https://github.com/olmoser))
- **[rules]** Rule parsing error. ([#3976](https://github.com/containous/traefik/pull/3976) by [ldez](https://github.com/ldez))
- Global configuration log at start ([#3954](https://github.com/containous/traefik/pull/3954) by [ldez](https://github.com/ldez))

**Documentation:**
- **[logs]** Document the default accessLog format ([#3942](https://github.com/containous/traefik/pull/3942) by [dfredell](https://github.com/dfredell))

## [v1.7.1](https://github.com/containous/traefik/tree/v1.7.1) (2018-09-28)
[All Commits](https://github.com/containous/traefik/compare/v1.7.0...v1.7.1)

**Bug fixes:**
- **[acme,cluster]** Don't remove static certs from config when cluster mode ([#3946](https://github.com/containous/traefik/pull/3946) by [Juliens](https://github.com/Juliens))
- **[acme]** Fix TLS ALPN cluster mode. ([#3934](https://github.com/containous/traefik/pull/3934) by [ldez](https://github.com/ldez))
- **[acme]** Don't challenge ACME when host rule on another entry point ([#3923](https://github.com/containous/traefik/pull/3923) by [Juliens](https://github.com/Juliens))
- **[tls]** Use the first static certificate as a fallback when no default is given ([#3948](https://github.com/containous/traefik/pull/3948) by [Juliens](https://github.com/Juliens))

## [v1.7.0](https://github.com/containous/traefik/tree/v1.7.0) (2018-09-24)
[Commits](https://github.com/containous/traefik/compare/v1.7.0-rc1...v1.7.0)
[Commits pre RC](https://github.com/containous/traefik/compare/v1.6.0-rc1...v1.7.0-rc1)
Expand Down
10 changes: 8 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion acme/acme.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ func (a *ACME) CreateClusterConfig(leadership *cluster.Leadership, tlsConfig *tl

a.checkOnDemandDomain = checkOnDemandDomain
a.dynamicCerts = certs
a.challengeTLSProvider = &challengeTLSProvider{store: a.store}

tlsConfig.GetCertificate = a.getCertificate
a.TLSConfig = tlsConfig
Expand Down Expand Up @@ -157,6 +156,7 @@ func (a *ACME) CreateClusterConfig(leadership *cluster.Leadership, tlsConfig *tl
}

a.store = datastore
a.challengeTLSProvider = &challengeTLSProvider{store: a.store}

ticker := time.NewTicker(24 * time.Hour)
leadership.Pool.AddGoCtx(func(ctx context.Context) {
Expand Down
35 changes: 35 additions & 0 deletions anonymize/anonymize_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package anonymize

import (
"crypto/tls"
"os"
"testing"
"time"

"github.com/containous/flaeg/parse"
"github.com/containous/traefik/acme"
"github.com/containous/traefik/api"
"github.com/containous/traefik/configuration"
"github.com/containous/traefik/middlewares"
"github.com/containous/traefik/provider"
acmeprovider "github.com/containous/traefik/provider/acme"
"github.com/containous/traefik/provider/boltdb"
Expand All @@ -25,8 +28,11 @@ import (
"github.com/containous/traefik/provider/mesos"
"github.com/containous/traefik/provider/rancher"
"github.com/containous/traefik/provider/zk"
"github.com/containous/traefik/safe"
traefiktls "github.com/containous/traefik/tls"
"github.com/containous/traefik/types"
"github.com/elazarl/go-bindata-assetfs"
"github.com/thoas/stats"
)

func TestDo_globalConfiguration(t *testing.T) {
Expand Down Expand Up @@ -192,6 +198,35 @@ func TestDo_globalConfiguration(t *testing.T) {
config.HealthCheck = &configuration.HealthCheckConfig{
Interval: parse.Duration(666 * time.Second),
}
config.API = &api.Handler{
EntryPoint: "traefik",
Dashboard: true,
Debug: true,
CurrentConfigurations: &safe.Safe{},
Statistics: &types.Statistics{
RecentErrors: 666,
},
Stats: &stats.Stats{
Uptime: time.Now(),
Pid: 666,
ResponseCounts: map[string]int{"foo": 1},
TotalResponseCounts: map[string]int{"bar": 1},
TotalResponseTime: time.Now(),
},
StatsRecorder: &middlewares.StatsRecorder{},
DashboardAssets: &assetfs.AssetFS{
Asset: func(path string) ([]byte, error) {
return nil, nil
},
AssetDir: func(path string) ([]string, error) {
return nil, nil
},
AssetInfo: func(path string) (os.FileInfo, error) {
return nil, nil
},
Prefix: "fii",
},
}
config.RespondingTimeouts = &configuration.RespondingTimeouts{
ReadTimeout: parse.Duration(666 * time.Second),
WriteTimeout: parse.Duration(666 * time.Second),
Expand Down
2 changes: 1 addition & 1 deletion api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Handler struct {
Statistics *types.Statistics `description:"Enable more detailed statistics" export:"true"`
Stats *thoas_stats.Stats `json:"-"`
StatsRecorder *middlewares.StatsRecorder `json:"-"`
DashboardAssets *assetfs.AssetFS
DashboardAssets *assetfs.AssetFS `json:"-"`
}

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/storeconfig/storeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func Run(kv *staert.KvSource, traefikConfiguration *cmd.TraefikConfiguration) fu
}

accountInitialized, err := keyExists(kv, traefikConfiguration.GlobalConfiguration.ACME.Storage)
if err != nil {
if err != nil && err != store.ErrKeyNotFound {
return err
}

Expand Down
15 changes: 10 additions & 5 deletions cmd/traefik/traefik.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,26 @@ func runCmd(globalConfiguration *configuration.GlobalConfiguration, configFile s
globalConfiguration.SetEffectiveConfiguration(configFile)
globalConfiguration.ValidateConfiguration()

log.Infof("Traefik version %s built on %s", version.Version, version.BuildDate)

jsonConf, err := json.Marshal(globalConfiguration)
if err != nil {
log.Error(err)
log.Debugf("Global configuration loaded [struct] %#v", globalConfiguration)
} else {
log.Debugf("Global configuration loaded %s", string(jsonConf))
}

if globalConfiguration.API != nil && globalConfiguration.API.Dashboard {
globalConfiguration.API.DashboardAssets = &assetfs.AssetFS{Asset: genstatic.Asset, AssetInfo: genstatic.AssetInfo, AssetDir: genstatic.AssetDir, Prefix: "static"}
}

jsonConf, _ := json.Marshal(globalConfiguration)
log.Infof("Traefik version %s built on %s", version.Version, version.BuildDate)

if globalConfiguration.CheckNewVersion {
checkNewVersion()
}

stats(globalConfiguration)

log.Debugf("Global configuration loaded %s", string(jsonConf))

providerAggregator := configuration.NewProviderAggregator(globalConfiguration)

acmeprovider := globalConfiguration.InitACMEProvider()
Expand Down
5 changes: 5 additions & 0 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ func (gc *GlobalConfiguration) SetEffectiveConfiguration(configFile string) {
if entryPoint.ForwardedHeaders == nil {
entryPoint.ForwardedHeaders = &ForwardedHeaders{}
}

if entryPoint.TLS != nil && entryPoint.TLS.DefaultCertificate == nil && len(entryPoint.TLS.Certificates) > 0 {
log.Infof("No tls.defaultCertificate given for %s: using the first item in tls.certificates as a fallback.", entryPointName)
entryPoint.TLS.DefaultCertificate = &entryPoint.TLS.Certificates[0]
}
}

// Make sure LifeCycle isn't nil to spare nil checks elsewhere.
Expand Down
21 changes: 20 additions & 1 deletion docs/configuration/logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,22 @@ For more information about the CLI, see the documentation about [Traefik command
By default the Traefik log is written to stdout in text format.

To write the logs into a log file specify the `filePath`:

```toml
[traefikLog]
filePath = "/path/to/traefik.log"
```

To write JSON format logs, specify `json` as the format:

```toml
[traefikLog]
filePath = "/path/to/traefik.log"
format = "json"
```

To customize the log level:

```toml
# Log level
#
Expand All @@ -92,24 +95,28 @@ Access logs are written when `[accessLog]` is defined.
By default it will write to stdout and produce logs in the textual Common Log Format (CLF), extended with additional fields.

To enable access logs using the default settings just add the `[accessLog]` entry:

```toml
[accessLog]
```

To write the logs into a log file specify the `filePath`:

```toml
[accessLog]
filePath = "/path/to/access.log"
```

To write JSON format logs, specify `json` as the format:

```toml
[accessLog]
filePath = "/path/to/access.log"
format = "json"
```

To write the logs in async, specify `bufferingSize` as the format (must be >0):

```toml
[accessLog]
filePath = "/path/to/access.log"
Expand All @@ -124,6 +131,7 @@ bufferingSize = 100
```

To filter logs you can specify a set of filters which are logically "OR-connected". Thus, specifying multiple filters will keep more access logs than specifying only one:

```toml
[accessLog]
filePath = "/path/to/access.log"
Expand Down Expand Up @@ -154,6 +162,7 @@ format = "json"
```

To customize logs format:

```toml
[accessLog]
filePath = "/path/to/access.log"
Expand Down Expand Up @@ -201,7 +210,8 @@ format = "json"
# ...
```

#### List of all available fields

### List of all available fields

```ini
StartUTC
Expand Down Expand Up @@ -236,6 +246,15 @@ Overhead
RetryAttempts
```

### CLF - Common Log Format

By default, Træfik use the CLF (`common`) as access log format.

```html
<remote_IP_address> - <client_user_name_if_available> [<timestamp>] "<request_method> <request_path> <request_protocol>" <origin_server_HTTP_status> <origin_server_content_size> "<request_referrer>" "<request_user_agent>" <number_of_requests_received_since_Traefik_started> "<Traefik_frontend_name>" "<Traefik_backend_URL>" <request_duration_in_ms>ms
```


## Log Rotation

Traefik will close and reopen its log files, assuming they're configured, on receipt of a USR1 signal.
Expand Down
7 changes: 4 additions & 3 deletions ip/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (s *DepthStrategy) GetIP(req *http.Request) string {
if len(xffs) < s.Depth {
return ""
}
return xffs[len(xffs)-s.Depth]
return strings.TrimSpace(xffs[len(xffs)-s.Depth])
}

// CheckerStrategy a strategy based on an IP Checker
Expand All @@ -54,8 +54,9 @@ func (s *CheckerStrategy) GetIP(req *http.Request) string {
xffs := strings.Split(xff, ",")

for i := len(xffs) - 1; i >= 0; i-- {
if contain, _ := s.Checker.Contains(xffs[i]); !contain {
return xffs[i]
xffTrimmed := strings.TrimSpace(xffs[i])
if contain, _ := s.Checker.Contains(xffTrimmed); !contain {
return xffTrimmed
}
}
return ""
Expand Down
12 changes: 12 additions & 0 deletions provider/acme/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,24 @@ func (p *Provider) initAccount() (*Account, error) {
return p.account, nil
}

func contains(entryPoints []string, acmeEntryPoint string) bool {
for _, entryPoint := range entryPoints {
if entryPoint == acmeEntryPoint {
return true
}
}
return false
}

func (p *Provider) watchNewDomains() {
p.pool.Go(func(stop chan bool) {
for {
select {
case config := <-p.configFromListenerChan:
for _, frontend := range config.Frontends {
if !contains(frontend.EntryPoints, p.EntryPoint) {
continue
}
for _, route := range frontend.Routes {
domainRules := rules.Rules{}
domains, err := domainRules.ParseDomains(route.Rule)
Expand Down
19 changes: 12 additions & 7 deletions provider/file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,21 @@ func TestProvideWithWatch(t *testing.T) {
}

timeout = time.After(time.Second * 1)
success := false
for !success {
var numUpdates, numBackends, numFrontends, numTLSConfs int
for {
select {
case config := <-configChan:
success = assert.Len(t, config.Configuration.Backends, test.expectedNumBackend)
success = success && assert.Len(t, config.Configuration.Frontends, test.expectedNumFrontend)
success = success && assert.Len(t, config.Configuration.TLS, test.expectedNumTLSConf)
numUpdates++
numBackends = len(config.Configuration.Backends)
numFrontends = len(config.Configuration.Frontends)
numTLSConfs = len(config.Configuration.TLS)
t.Logf("received update #%d: backends %d/%d, frontends %d/%d, TLS configs %d/%d", numUpdates, numBackends, test.expectedNumBackend, numFrontends, test.expectedNumFrontend, numTLSConfs, test.expectedNumTLSConf)

if numBackends == test.expectedNumBackend && numFrontends == test.expectedNumFrontend && numTLSConfs == test.expectedNumTLSConf {
return
}
case <-timeout:
t.Errorf("timeout while waiting for config")
return
t.Fatal("timeout while waiting for config")
}
}
})
Expand Down
9 changes: 9 additions & 0 deletions provider/kubernetes/annotations.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package kubernetes

import (
"strconv"

"github.com/containous/traefik/provider/label"
)

Expand Down Expand Up @@ -85,6 +87,13 @@ func getStringValue(annotations map[string]string, annotation string, defaultVal
return label.GetStringValue(annotations, annotationName, defaultValue)
}

func getStringSafeValue(annotations map[string]string, annotation string, defaultValue string) (string, error) {
annotationName := getAnnotationName(annotations, annotation)
value := label.GetStringValue(annotations, annotationName, defaultValue)
_, err := strconv.Unquote(`"` + value + `"`)
return value, err
}

func getBoolValue(annotations map[string]string, annotation string, defaultValue bool) bool {
annotationName := getAnnotationName(annotations, annotation)
return label.GetBoolValue(annotations, annotationName, defaultValue)
Expand Down
Loading

0 comments on commit 05f052b

Please sign in to comment.