Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.6-alpine
RUN apk add -U git make
RUN go get github.com/tools/godep
RUN apk add -U git make curl
RUN go get github.com/Masterminds/glide
ENV DOCKER_VERSION 1.10.3
ENV APP interlock
ENV REPO ehazlett/$APP
Expand Down
2 changes: 2 additions & 0 deletions ext/lb/nginx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type Host struct {
Upstream *Upstream
WebsocketEndpoints []string
IPHash bool
Check string
CheckInterval int
}
type Config struct {
Hosts []*Host
Expand Down
28 changes: 28 additions & 0 deletions ext/lb/nginx/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
func (p *NginxLoadBalancer) GenerateProxyConfig(containers []dockerclient.Container) (interface{}, error) {
var hosts []*Host
upstreamServers := map[string][]string{}
hostChecks := map[string]string{}
hostCheckIntervals := map[string]int{}
serverNames := map[string][]string{}
hostContextRoots := map[string]*ContextRoot{}
hostContextRootRewrites := map[string]bool{}
Expand Down Expand Up @@ -59,12 +61,35 @@ func (p *NginxLoadBalancer) GenerateProxyConfig(containers []dockerclient.Contai
}
hostContextRootRewrites[domain] = utils.ContextRootRewrite(cInfo.Config)


// check if the first server name is there; if not, add
// this happens if there are multiple backend containers
if _, ok := serverNames[domain]; !ok {
serverNames[domain] = []string{domain}
}

healthCheck := utils.HealthCheck(cInfo.Config)
healthCheckInterval, err := utils.HealthCheckInterval(cInfo.Config)
if err != nil {
log().Errorf("error parsing health check interval: %s", err)
continue
}

if healthCheck != "" {
if val, ok := hostChecks[domain]; ok {
// check existing host check for different values
if val != healthCheck {
log().Warnf("conflicting check specified for %s", domain)
}
} else {
hostChecks[domain] = healthCheck
hostCheckIntervals[domain] = healthCheckInterval
log().Debugf("using custom check for %s: %s", domain, healthCheck)
}

log().Debugf("check interval for %s: %d", domain, healthCheckInterval)
}

hostSSL[domain] = utils.SSLEnabled(cInfo.Config)
hostSSLOnly[domain] = utils.SSLOnly(cInfo.Config)
hostIPHash[domain] = utils.IPHash(cInfo.Config)
Expand Down Expand Up @@ -159,6 +184,8 @@ func (p *NginxLoadBalancer) GenerateProxyConfig(containers []dockerclient.Contai
Port: p.cfg.Port,
ContextRoot: hostContextRoots[k],
ContextRootRewrite: hostContextRootRewrites[k],
Check: hostChecks[k],
CheckInterval: hostCheckIntervals[k],
SSLPort: p.cfg.SSLPort,
SSL: hostSSL[k],
SSLCert: hostSSLCert[k],
Expand All @@ -183,6 +210,7 @@ func (p *NginxLoadBalancer) GenerateProxyConfig(containers []dockerclient.Contai
Name: k,
Servers: servers,
}

h.Upstream = up

hosts = append(hosts, h)
Expand Down
2 changes: 1 addition & 1 deletion ext/lb/utils/health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

const (
DefaultHealthCheckInterval = 5000
DefaultHealthCheckInterval = 10000
)

func HealthCheck(config *dockerclient.ContainerConfig) string {
Expand Down