Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route security management by end user #14536

Merged
merged 1 commit into from
Jun 15, 2017
Merged
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
26 changes: 26 additions & 0 deletions images/router/haproxy/conf/haproxy-config.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
{{- define "/var/lib/haproxy/conf/haproxy.config" }}
{{- $workingDir := .WorkingDir }}
{{- $defaultDestinationCA := .DefaultDestinationCA }}

{{/* A bunch of regular expressions. Each should be wrapped in (?:) so that it is safe to include bare */}}
{{/* quadPattern: Match a quad in an IP address; e.g. 123 */}}
{{- $quadPattern := `(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])` -}}

{{/* ipPattern: Match an IPv4 address; e.g. 192.168.21.23 */}}
{{- $ipPattern := printf `(?:%s\.%s\.%s\.%s)` $quadPattern $quadPattern $quadPattern $quadPattern -}}

{{/* cidrPattern: Match an IP and network size in CIDR form; e.g. 192.168.21.23/24 */}}
{{- $cidrPattern := printf `(?:%s(?:/(?:[0-9]|[1-2][0-9]|3[0-2]))?)` $ipPattern -}}

{{/* cidrListPattern: Match a space separated list of CIDRs; e.g. 192.168.21.23/24 192.10.2.12 */}}
{{- $cidrListPattern := printf `(?:%s(?: +%s)*)` $cidrPattern $cidrPattern -}}

global
maxconn {{env "ROUTER_MAX_CONNECTIONS" "20000"}}

Expand Down Expand Up @@ -293,6 +307,12 @@ backend be_secure:{{$cfgIdx}}
balance {{ if gt $cfg.ActiveServiceUnits 1 }}roundrobin{{ else }}leastconn{{ end }}
{{- end }}
{{- end }}
{{- with $ip_whiteList := index $cfg.Annotations "haproxy.router.openshift.io/ip_whitelist" }}
{{- if (matchPattern $cidrListPattern $ip_whiteList) }}
acl whitelist src {{ $ip_whiteList }}
tcp-request content reject if !whitelist
{{- end }}
{{- end }}
{{- with $value := index $cfg.Annotations "haproxy.router.openshift.io/timeout"}}
{{- if (matchPattern "[1-9][0-9]*(us|ms|s|m|h|d)?" $value) }}
timeout server {{$value}}
Expand Down Expand Up @@ -390,6 +410,12 @@ backend be_tcp:{{$cfgIdx}}
balance {{ if gt $cfg.ActiveServiceUnits 1 }}roundrobin{{ else }}source{{ end }}
{{- end }}
{{- end }}
{{- with $ip_whiteList := index $cfg.Annotations "haproxy.router.openshift.io/ip_whitelist" }}
{{- if (matchPattern $cidrListPattern $ip_whiteList) }}
acl whitelist src {{$ip_whiteList}}
tcp-request content reject if !whitelist
{{- end }}
{{- end }}
{{- with $value := index $cfg.Annotations "haproxy.router.openshift.io/timeout"}}
{{- if (matchPattern "[1-9][0-9]*(us|ms|s|m|h|d)?" $value) }}
timeout tunnel {{$value}}
Expand Down