Skip to content

Commit fc9f272

Browse files
author
Viktor Farcic
committed
2 parents 5d14529 + 83a7fd8 commit fc9f272

7 files changed

Lines changed: 169 additions & 47 deletions

File tree

Dockerfile

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
FROM golang:1.9.6 AS build
1+
FROM golang:1.11.0-alpine AS build
22
ADD . /src
33
WORKDIR /src
4-
RUN go get -d -v -t
5-
RUN go test --cover ./... --run UnitTest
6-
RUN go build -v -o docker-flow-proxy
4+
RUN set -x \
5+
&& apk add --update --no-cache --no-progress git g++ \
6+
&& go get -d -v -t \
7+
&& go test --cover ./... --run UnitTest \
8+
&& go build -v -o docker-flow-proxy
79

810

9-
FROM haproxy:1.8.8-alpine
10-
MAINTAINER Viktor Farcic <viktor@farcic.com>
11+
FROM haproxy:1.8.13-alpine
12+
LABEL org.opencontainers.image.title="Docker Flow Proxy" \
13+
org.opencontainers.image.description="Automated HAProxy Reverse Proxy for Docker" \
14+
org.opencontainers.image.url="https://proxy.dockerflow.com" \
15+
org.opencontainers.image.licenses="MIT" \
16+
org.opencontainers.image.authors="Viktor Farcic <viktor@farcic.com>" \
17+
org.opencontainers.image.source="https://github.com/docker-flow/docker-flow-proxy"
1118

12-
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
13-
RUN mkdir -p /cfg/tmpl /templates /certs /logs
19+
RUN apk --update --no-cache --no-progress add tini \
20+
&& mkdir -p /cfg/tmpl /templates /certs /logs
1421

1522
ENV CERTS="" \
1623
CAPTURE_REQUEST_HEADER="" \
@@ -39,21 +46,20 @@ ENV CERTS="" \
3946
TIMEOUT_HTTP_REQUEST="5" TIMEOUT_HTTP_KEEP_ALIVE="15" TIMEOUT_CLIENT="20" TIMEOUT_CONNECT="5" TIMEOUT_QUEUE="30" TIMEOUT_SERVER="20" TIMEOUT_TUNNEL="3600" \
4047
USERS="" \
4148
SKIP_ADDRESS_VALIDATION="true" \
42-
SSL_BIND_OPTIONS="no-sslv3" SSL_BIND_CIPHERS="ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS"
49+
SSL_BIND_OPTIONS="ssl-min-ver TLSv1.2 no-tls-tickets" \
50+
SSL_BIND_CIPHERS="ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:EECDH+AESGCM:EDH+AESGCM"
4351

44-
EXPOSE 80
45-
EXPOSE 443
46-
EXPOSE 8080
52+
EXPOSE 80 \
53+
443 \
54+
8080
4755

48-
RUN apk --no-cache add tini
4956
ENTRYPOINT ["/sbin/tini", "-g", "--"]
5057
CMD ["docker-flow-proxy", "server"]
5158
HEALTHCHECK --interval=5s --start-period=3s --timeout=10s CMD check.sh
5259

5360
COPY scripts/check.sh /usr/local/bin/check.sh
54-
RUN chmod +x /usr/local/bin/check.sh
5561
COPY errorfiles /errorfiles
5662
COPY haproxy.cfg /cfg/haproxy.cfg
5763
COPY haproxy.tmpl /cfg/tmpl/haproxy.tmpl
5864
COPY --from=build /src/docker-flow-proxy /usr/local/bin/docker-flow-proxy
59-
RUN chmod +x /usr/local/bin/docker-flow-proxy
65+
RUN chmod +x /usr/local/bin/docker-flow-proxy /usr/local/bin/check.sh

actions/reconfigure_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,8 @@ func (s ReconfigureTestSuite) Test_Execute_WritesServerSession() {
741741
s.reconfigure.AclName = "my-service"
742742
s.reconfigure.ServiceDest[0].Port = "1111"
743743
s.reconfigure.ServiceDest[0].HttpsPort = 2222
744-
s.reconfigure.Tasks = []string{"1.2.3.4", "4.3.2.1"}
744+
// The expectedData will place these ips in order
745+
s.reconfigure.Tasks = []string{"4.3.2.1", "1.2.3.4"}
745746
s.reconfigure.SessionType = "sticky-server"
746747
var actualData string
747748
expectedData := `

docs/config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ The following environment variables can be used to configure the *Docker Flow Pr
4545
|SERVICE_DOMAIN_ALGO|The default algorithm applied to domain ACLs. It can be overwritten for a service through the `serviceDomainAlgo` parameter.<br>**Examples:**<br>`hdr(host)`: matches only if domain is the same as `serviceDomain`<br>`hdr_dom(host)`: matches the specified `serviceDomain` and any subdomain (a string either isolated or delimited by dots).<br>`req.ssl_sni`: matches Server Name TLS extension<br>**Default Value:** `hdr_beg(host)`|
4646
|SERVICE_NAME |The name of the service. It must be the same as the value of the `--name` argument used to create the proxy service. Used only in the *swarm* mode.<br>**Example:** `my-proxy`<br>**Default value:** `proxy`|
4747
|SKIP_ADDRESS_VALIDATION|Whether to skip validating service address before reconfiguring the proxy.<br>**Example:** false<br>**Default value:** `true`|
48-
|SSL_BIND_CIPHERS |Sets the default string describing the list of cipher algorithms ("cipher suite") that are negotiated during the SSL/TLS handshake for all "bind" lines which do not explicitly define theirs. The format of the string is defined in "man 1 ciphers" from OpenSSL man pages, and can be for instance a string such as `AES:ALL:!aNULL:!eNULL:+RC4:@STRENGTH`.<br>**Default value:** see [Dockerfile](https://github.com/docker-flow/docker-flow-proxy/blob/master/Dockerfile#L31)|
49-
|SSL_BIND_OPTIONS |Sets default ssl-options to force on all "bind" lines.<br>**Default value:** `no-sslv3`|
48+
|SSL_BIND_CIPHERS |Sets the default string describing the list of cipher algorithms ("cipher suite") that are negotiated during the SSL/TLS handshake for all "bind" lines which do not explicitly define theirs. The format of the string is defined in "man 1 ciphers" from OpenSSL man pages, and can be for instance a string such as `EECDH+AESGCM:EDH+AESGCM`.<br>**Default value:** see [Dockerfile](https://github.com/docker-flow/docker-flow-proxy/blob/master/Dockerfile#L42)|
49+
|SSL_BIND_OPTIONS |Sets default ssl-options to force on all "bind" lines.<br>**Default value:** `ssl-min-ver TLSv1.2 no-tls-tickets`|
5050
|STATS_USER |Username for the statistics page. If not set, stats will not be available. If both `STATS_USER` and `STATS_PASS` are set to `none`, statistics will be available without authentication.<br>**Example:** my-user<br>**Default value:** `admin`|
5151
|STATS_USER_ENV |The name of the environment variable that holds the username for the statistics page.<br>**Example:** MY_USER<br>**Default value:** `STATS_USER`|
5252
|STATS_PASS |Password for the statistics page. If not set, stats will not be available. If both `STATS_USER` and `STATS_PASS` are set to `none`, statistics will be available without authentication.<br>**Example:** my-pass<br>**Default value:** `admin`|

logging/logging_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (s LoggingTestSuite) Test_StartLogging_OutputsSyslogToStdOut() {
4141
expected := fmt.Sprintf("This is a syslog message %d", i)
4242
go sysLog.Info(expected)
4343
logged := false
44-
for c := 0; c < 200; c++ {
44+
for c := 0; c < 1000; c++ {
4545
if strings.Contains(actual, expected) {
4646
logged = true
4747
break

proxy/ha_proxy.go

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,25 @@ backend dummy-be
302302
}
303303

304304
func (m HaProxy) getConfigData() configData {
305+
306+
services := Services{}
307+
hasHTTP := false
308+
for _, s := range dataInstance.Services {
309+
if len(s.AclName) == 0 {
310+
s.AclName = s.ServiceName
311+
}
312+
services = append(services, s)
313+
for i := range s.ServiceDest {
314+
if len(s.ServiceDest[i].ReqMode) == 0 {
315+
s.ServiceDest[i].ReqMode = "http"
316+
}
317+
if s.ServiceDest[i].ReqMode == "http" {
318+
hasHTTP = true
319+
}
320+
}
321+
}
322+
includeDefaultPorts := (len(services) == 0) || hasHTTP
323+
305324
d := configData{
306325
CertsString: m.getCertsConfigSnippet(),
307326
}
@@ -328,11 +347,13 @@ func (m HaProxy) getConfigData() configData {
328347
m.addCompression(&d)
329348
m.addDebug(&d)
330349

331-
defaultPortsString := getSecretOrEnvVar("DEFAULT_PORTS", "")
332-
defaultPorts := strings.Split(defaultPortsString, ",")
333-
for _, bindPort := range defaultPorts {
334-
formattedPort := strings.Replace(bindPort, ":ssl", d.CertsString, -1)
335-
d.DefaultBinds += fmt.Sprintf("\n bind *:%s", formattedPort)
350+
if includeDefaultPorts {
351+
defaultPortsString := getSecretOrEnvVar("DEFAULT_PORTS", "")
352+
defaultPorts := strings.Split(defaultPortsString, ",")
353+
for _, bindPort := range defaultPorts {
354+
formattedPort := strings.Replace(bindPort, ":ssl", d.CertsString, -1)
355+
d.DefaultBinds += fmt.Sprintf("\n bind *:%s", formattedPort)
356+
}
336357
}
337358
extraGlobal := getSecretOrEnvVarSplit("EXTRA_GLOBAL", "")
338359
if len(extraGlobal) > 0 {
@@ -356,18 +377,6 @@ func (m HaProxy) getConfigData() configData {
356377
values[1])
357378
}
358379
}
359-
services := Services{}
360-
for _, s := range dataInstance.Services {
361-
if len(s.AclName) == 0 {
362-
s.AclName = s.ServiceName
363-
}
364-
services = append(services, s)
365-
for i := range s.ServiceDest {
366-
if len(s.ServiceDest[i].ReqMode) == 0 {
367-
s.ServiceDest[i].ReqMode = "http"
368-
}
369-
}
370-
}
371380
m.getSni(&services, &d)
372381
return d
373382
}

0 commit comments

Comments
 (0)