Skip to content

Commit

Permalink
Removed statistics if STATS_USER and STATS_PASS are not set.
Browse files Browse the repository at this point in the history
  • Loading branch information
vfarcic committed Mar 21, 2017
1 parent 268fa36 commit 5762086
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ENV CONNECTION_MODE="http-server-close" \
MODE="default" \
PROXY_INSTANCE_NAME="docker-flow" \
SERVICE_NAME="proxy" \
STATS_USER="admin" STATS_USER_ENV="STATS_USER" STATS_PASS="admin" STATS_PASS_ENV="STATS_PASS" \
STATS_USER="" STATS_USER_ENV="STATS_USER" STATS_PASS="" STATS_PASS_ENV="STATS_PASS" \
TIMEOUT_HTTP_REQUEST="5" TIMEOUT_HTTP_KEEP_ALIVE="15" TIMEOUT_CLIENT="20" TIMEOUT_CONNECT="5" TIMEOUT_QUEUE="30" TIMEOUT_SERVER="20" TIMEOUT_TUNNEL="3600" \
USERS="" \
EXTRA_FRONTEND="" \
Expand Down
4 changes: 2 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ The following environment variables can be used to configure the *Docker Flow Pr
|PROXY_INSTANCE_NAME|The name of the proxy instance. Useful if multiple proxies are running inside a cluster|No|docker-flow|docker-flow|
|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.|No|proxy|my-proxy|
|SKIP_ADDRESS_VALIDATION|Whether to skip validating service address before reconfiguring the proxy.|No|false|true|
|STATS_USER |Username for the statistics page |No |admin |my-user|
|STATS_USER |Username for the statistics page. If not set, stats will not be available.|No |admin |my-user|
|STATS_USER_ENV |The name of the environment variable that holds the username for the statistics page|No|STATS_USER|MY_USER|
|STATS_PASS |Password for the statistics page |No |admin |my-pass|
|STATS_PASS |Password for the statistics page. If not set, stats will not be available.|No |admin |my-pass|
|STATS_PASS_ENV |The name of the environment variable that holds the password for the statistics page|No|STATS_PASS|MY_PASS|
|TIMEOUT_CLIENT |The client timeout in seconds |No |20 |5 |
|TIMEOUT_CONNECT |The connect timeout in seconds |No |5 |3 |
Expand Down
7 changes: 1 addition & 6 deletions haproxy.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ defaults
timeout tunnel {{.TimeoutTunnel}}s
timeout http-request {{.TimeoutHttpRequest}}s
timeout http-keep-alive {{.TimeoutHttpKeepAlive}}s

stats enable
stats refresh 30s
stats realm Strictly\ Private
stats auth {{.StatsUser}}:{{.StatsPass}}
stats uri /admin?stats
{{.Stats}}
{{.UserList}}
frontend services{{.DefaultBinds}}
mode http
Expand Down
18 changes: 14 additions & 4 deletions proxy/ha_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ type ConfigData struct {
TimeoutTunnel string
TimeoutHttpRequest string
TimeoutHttpKeepAlive string
StatsUser string
StatsPass string
Stats string
UserList string
ExtraGlobal string
ExtraDefaults string
Expand Down Expand Up @@ -198,8 +197,19 @@ func (m HaProxy) getConfigData() ConfigData {
d.TimeoutTunnel = GetSecretOrEnvVar("TIMEOUT_TUNNEL", "3600")
d.TimeoutHttpRequest = GetSecretOrEnvVar("TIMEOUT_HTTP_REQUEST", "5")
d.TimeoutHttpKeepAlive = GetSecretOrEnvVar("TIMEOUT_HTTP_KEEP_ALIVE", "15")
d.StatsUser = GetSecretOrEnvVar(os.Getenv("STATS_USER_ENV"), "admin")
d.StatsPass = GetSecretOrEnvVar(os.Getenv("STATS_PASS_ENV"), "admin")
statsUser := GetSecretOrEnvVar(os.Getenv("STATS_USER_ENV"), "admin")
statsPass := GetSecretOrEnvVar(os.Getenv("STATS_PASS_ENV"), "admin")
if len(statsUser) > 0 && len(statsPass) > 0 {
d.Stats = fmt.Sprintf(`
stats enable
stats refresh 30s
stats realm Strictly\ Private
stats auth %s:%s
stats uri /admin?stats`,
statsUser,
statsPass,
)
}
usersString := GetSecretOrEnvVar("USERS", "")
encryptedString := GetSecretOrEnvVar("USERS_PASS_ENCRYPTED", "")
if len(usersString) > 0 {
Expand Down
7 changes: 1 addition & 6 deletions proxy/test_configs/tmpl/haproxy.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ defaults
timeout tunnel {{.TimeoutTunnel}}s
timeout http-request {{.TimeoutHttpRequest}}s
timeout http-keep-alive {{.TimeoutHttpKeepAlive}}s

stats enable
stats refresh 30s
stats realm Strictly\ Private
stats auth {{.StatsUser}}:{{.StatsPass}}
stats uri /admin?stats
{{.Stats}}
{{.UserList}}
frontend services{{.DefaultBinds}}
mode http
Expand Down

0 comments on commit 5762086

Please sign in to comment.