diff --git a/cmd/traefik/configuration.go b/cmd/traefik/configuration.go index b61c9d50d..320b7a9eb 100644 --- a/cmd/traefik/configuration.go +++ b/cmd/traefik/configuration.go @@ -159,25 +159,42 @@ func NewTraefikDefaultPointersConfiguration() *TraefikConfiguration { FilePath: "", } + // default HealthCheckConfig + healthCheck := configuration.HealthCheckConfig{ + Interval: flaeg.Duration(configuration.DefaultHealthCheckInterval), + } + + // default RespondingTimeouts + respondingTimeouts := configuration.RespondingTimeouts{ + IdleTimeout: flaeg.Duration(configuration.DefaultIdleTimeout), + } + + // default ForwardingTimeouts + forwardingTimeouts := configuration.ForwardingTimeouts{ + DialTimeout: flaeg.Duration(configuration.DefaultDialTimeout), + } + defaultConfiguration := configuration.GlobalConfiguration{ - Docker: &defaultDocker, - File: &defaultFile, - Web: &defaultWeb, - Marathon: &defaultMarathon, - Consul: &defaultConsul, - ConsulCatalog: &defaultConsulCatalog, - Etcd: &defaultEtcd, - Zookeeper: &defaultZookeeper, - Boltdb: &defaultBoltDb, - Kubernetes: &defaultKubernetes, - Mesos: &defaultMesos, - ECS: &defaultECS, - Rancher: &defaultRancher, - Eureka: &defaultEureka, - DynamoDB: &defaultDynamoDB, - Retry: &configuration.Retry{}, - HealthCheck: &configuration.HealthCheckConfig{}, - AccessLog: &defaultAccessLog, + Docker: &defaultDocker, + File: &defaultFile, + Web: &defaultWeb, + Marathon: &defaultMarathon, + Consul: &defaultConsul, + ConsulCatalog: &defaultConsulCatalog, + Etcd: &defaultEtcd, + Zookeeper: &defaultZookeeper, + Boltdb: &defaultBoltDb, + Kubernetes: &defaultKubernetes, + Mesos: &defaultMesos, + ECS: &defaultECS, + Rancher: &defaultRancher, + Eureka: &defaultEureka, + DynamoDB: &defaultDynamoDB, + Retry: &configuration.Retry{}, + HealthCheck: &healthCheck, + AccessLog: &defaultAccessLog, + RespondingTimeouts: &respondingTimeouts, + ForwardingTimeouts: &forwardingTimeouts, } return &TraefikConfiguration{ @@ -202,12 +219,6 @@ func NewTraefikConfiguration() *TraefikConfiguration { HealthCheck: &configuration.HealthCheckConfig{ Interval: flaeg.Duration(configuration.DefaultHealthCheckInterval), }, - RespondingTimeouts: &configuration.RespondingTimeouts{ - IdleTimeout: flaeg.Duration(configuration.DefaultIdleTimeout), - }, - ForwardingTimeouts: &configuration.ForwardingTimeouts{ - DialTimeout: flaeg.Duration(configuration.DefaultDialTimeout), - }, CheckNewVersion: true, }, ConfigFile: "", diff --git a/server/server.go b/server/server.go index a188dd8cb..e13dff8fd 100644 --- a/server/server.go +++ b/server/server.go @@ -127,7 +127,7 @@ func NewServer(globalConfiguration configuration.GlobalConfiguration) *Server { // behaviour and backwards compatibility issues. func createHTTPTransport(globalConfiguration configuration.GlobalConfiguration) *http.Transport { dialer := &net.Dialer{ - Timeout: 30 * time.Second, + Timeout: configuration.DefaultDialTimeout, KeepAlive: 30 * time.Second, DualStack: true, } @@ -675,14 +675,13 @@ func buildServerTimeouts(globalConfig configuration.GlobalConfiguration) (readTi writeTimeout = time.Duration(globalConfig.RespondingTimeouts.WriteTimeout) } - // When RespondingTimeouts.IdleTimout is configured, always use that setting - if globalConfig.RespondingTimeouts != nil { - idleTimeout = time.Duration(globalConfig.RespondingTimeouts.IdleTimeout) - } else if globalConfig.IdleTimeout != 0 { - // Backwards compatibility for deprecated IdleTimeout + // Prefer legacy idle timeout parameter for backwards compatibility reasons + if globalConfig.IdleTimeout > 0 { idleTimeout = time.Duration(globalConfig.IdleTimeout) + log.Warn("top-level idle timeout configuration has been deprecated -- please use responding timeouts") + } else if globalConfig.RespondingTimeouts != nil { + idleTimeout = time.Duration(globalConfig.RespondingTimeouts.IdleTimeout) } else { - // Default value if neither the deprecated IdleTimeout nor the new RespondingTimeouts.IdleTimout are configured idleTimeout = time.Duration(configuration.DefaultIdleTimeout) } diff --git a/server/server_test.go b/server/server_test.go index 8d47c7831..a1575fddb 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -83,7 +83,7 @@ func TestPrepareServerTimeouts(t *testing.T) { IdleTimeout: flaeg.Duration(80 * time.Second), }, }, - wantIdleTimeout: time.Duration(80 * time.Second), + wantIdleTimeout: time.Duration(45 * time.Second), wantReadTimeout: time.Duration(0 * time.Second), wantWriteTimeout: time.Duration(0 * time.Second), },