-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Combine backend map files to fix path based routing #18840
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,15 +164,7 @@ frontend public | |
acl secure_redirect base,map_reg(/var/lib/haproxy/conf/os_route_http_redirect.map) -m found | ||
redirect scheme https if secure_redirect | ||
|
||
# Check if it is an edge or reencrypt route exposed insecurely. | ||
acl route_http_expose base,map_reg(/var/lib/haproxy/conf/os_route_http_expose.map) -m found | ||
use_backend %[base,map_reg(/var/lib/haproxy/conf/os_route_http_expose.map)] if route_http_expose | ||
|
||
# map to http backend | ||
# Search from most specific to general path (host case). | ||
# Note: If no match, haproxy uses the default_backend, no other | ||
# use_backend directives below this will be processed. | ||
use_backend be_http:%[base,map_reg(/var/lib/haproxy/conf/os_http_be.map)] | ||
use_backend %[base,map_reg(/var/lib/haproxy/conf/os_http_be.map)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason why you only added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I left out the redirects because that is a specific operation that does not link to a use_backend statement. It is determining to allow redirect based on if there is an entry in the map. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries - I was just asking. I've made the change in my branch to make it consistent as part of the dynamic config changes anyway so its cool. |
||
|
||
default_backend openshift_default | ||
|
||
|
@@ -233,17 +225,11 @@ frontend fe_sni | |
# before matching, or any requests containing uppercase characters will never match. | ||
http-request set-header Host %[req.hdr(Host),lower] | ||
|
||
# check re-encrypt backends first - from most specific to general path. | ||
acl reencrypt base,map_reg(/var/lib/haproxy/conf/os_reencrypt.map) -m found | ||
|
||
# Search from most specific to general path (host case). | ||
use_backend be_secure:%[base,map_reg(/var/lib/haproxy/conf/os_reencrypt.map)] if reencrypt | ||
|
||
# map to http backend | ||
# map to backend | ||
# Search from most specific to general path (host case). | ||
# Note: If no match, haproxy uses the default_backend, no other | ||
# use_backend directives below this will be processed. | ||
use_backend be_edge_http:%[base,map_reg(/var/lib/haproxy/conf/os_edge_http_be.map)] | ||
use_backend %[base,map_reg(/var/lib/haproxy/conf/os_edge_reencrypt_be.map)] | ||
|
||
default_backend openshift_default | ||
|
||
|
@@ -274,17 +260,12 @@ frontend fe_no_sni | |
# before matching, or any requests containing uppercase characters will never match. | ||
http-request set-header Host %[req.hdr(Host),lower] | ||
|
||
# check re-encrypt backends first - path or host based. | ||
acl reencrypt base,map_reg(/var/lib/haproxy/conf/os_reencrypt.map) -m found | ||
|
||
# Search from most specific to general path (host case). | ||
use_backend be_secure:%[base,map_reg(/var/lib/haproxy/conf/os_reencrypt.map)] if reencrypt | ||
|
||
# map to http backend | ||
# map to backend | ||
# Search from most specific to general path (host case). | ||
# Note: If no match, haproxy uses the default_backend, no other | ||
# use_backend directives below this will be processed. | ||
use_backend be_edge_http:%[base,map_reg(/var/lib/haproxy/conf/os_edge_http_be.map)] | ||
use_backend %[base,map_reg(/var/lib/haproxy/conf/os_edge_reencrypt_be.map)] | ||
|
||
default_backend openshift_default | ||
|
||
|
@@ -494,46 +475,45 @@ backend be_tcp:{{$cfgIdx}} | |
{{ end -}}{{/* end if router allows wildcard routes */}} | ||
{{ end -}}{{/* end wildcard domain map template */}} | ||
|
||
|
||
|
||
{{/* | ||
os_http_be.map: contains a mapping of www.example.com -> <service name>. This map is used to discover the correct backend | ||
by attaching a prefix (be_http:) by use_backend statements if acls are matched. | ||
os_http_be.map : contains a mapping of www.example.com -> <service name>. This map is used to discover the correct backend | ||
by attaching a prefix: be_http for http routes | ||
be_edge_http for edge routes with InsecureEdgeTerminationPolicy Allow | ||
be_secure for reencrypt routes with InsecureEdgeTerminationPolicy Allow | ||
*/}} | ||
{{ define "/var/lib/haproxy/conf/os_http_be.map" -}} | ||
{{ range $idx, $cfg := .State -}} | ||
{{ if and (ne $cfg.Host "") (eq $cfg.TLSTermination "") -}} | ||
{{generateRouteRegexp $cfg.Host $cfg.Path $cfg.IsWildcard}} {{$idx}} | ||
{{generateRouteRegexp $cfg.Host $cfg.Path $cfg.IsWildcard}} be_http:{{$idx}} | ||
{{ end -}} | ||
{{ end -}} | ||
{{ end -}}{{/* end http host map template */}} | ||
|
||
{{/* | ||
os_edge_http_be.map: same as os_http_be.map but allows us to separate tls from non-tls routes to ensure we don't expose | ||
a tls only route on the unsecure port | ||
*/}} | ||
{{ define "/var/lib/haproxy/conf/os_edge_http_be.map" -}} | ||
{{ range $idx, $cfg := .State -}} | ||
{{ if and (ne $cfg.Host "") (eq $cfg.TLSTermination "edge") -}} | ||
{{generateRouteRegexp $cfg.Host $cfg.Path $cfg.IsWildcard}} {{$idx}} | ||
{{ if and (ne $cfg.Host "") (and (matchValues (print $cfg.TLSTermination) "edge" "reencrypt") (eq $cfg.InsecureEdgeTerminationPolicy "Allow")) -}} | ||
{{ if (eq $cfg.TLSTermination "edge") -}} | ||
{{generateRouteRegexp $cfg.Host $cfg.Path $cfg.IsWildcard}} be_edge_http:{{$idx}} | ||
{{ else -}} | ||
{{generateRouteRegexp $cfg.Host $cfg.Path $cfg.IsWildcard}} be_secure:{{$idx}} | ||
{{ end -}} | ||
{{ end -}} | ||
{{ end -}} | ||
{{ end -}}{{/* end edge http host map template */}} | ||
{{ end -}} | ||
|
||
{{/* | ||
os_route_http_expose.map: contains a mapping of www.example.com -> <service name>. | ||
Map is used to also expose edge terminated and reencrypt routes via an insecure scheme | ||
(http) if acls match for routes with insecure option set to expose. | ||
os_edge_reencrypt_be.map : contains a mapping of www.example.com -> <service name>. This map is similar to os_http_be.map but for tls routes. | ||
by attaching prefix: be_edge_http for edge terminated routes | ||
be_secure for reencrypt routes | ||
*/}} | ||
{{ define "/var/lib/haproxy/conf/os_route_http_expose.map" -}} | ||
{{ define "/var/lib/haproxy/conf/os_edge_reencrypt_be.map" -}} | ||
{{ range $idx, $cfg := .State -}} | ||
{{ if and (ne $cfg.Host "") (and (matchValues (print $cfg.TLSTermination) "edge" "reencrypt") (eq $cfg.InsecureEdgeTerminationPolicy "Allow")) -}} | ||
{{ if (eq $cfg.TLSTermination "edge") -}} | ||
{{ if and (ne $cfg.Host "") (eq $cfg.TLSTermination "edge") -}} | ||
{{generateRouteRegexp $cfg.Host $cfg.Path $cfg.IsWildcard}} be_edge_http:{{$idx}} | ||
{{ else -}} | ||
{{ end -}} | ||
{{ if and (ne $cfg.Host "") (eq $cfg.TLSTermination "reencrypt") -}} | ||
{{generateRouteRegexp $cfg.Host $cfg.Path $cfg.IsWildcard}} be_secure:{{$idx}} | ||
{{ end -}} | ||
{{ end -}} | ||
{{ end -}} | ||
{{ end -}}{{/* end edge and reencrypt expose http host map template */}} | ||
{{ end -}}{{/* end edge http host map template */}} | ||
|
||
|
||
{{/* | ||
os_route_http_redirect.map: contains a mapping of www.example.com -> <service name>. | ||
|
@@ -573,19 +553,6 @@ backend be_tcp:{{$cfgIdx}} | |
{{ end -}} | ||
{{ end -}}{{/* end sni passthrough map template */}} | ||
|
||
|
||
{{/* | ||
os_reencrypt.map: marker that the host is configured to use a secure backend, allows the selection of a backend | ||
that does specific checks that avoid mitm attacks: http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#5.2-ssl | ||
*/}} | ||
{{ define "/var/lib/haproxy/conf/os_reencrypt.map" -}} | ||
{{ range $idx, $cfg := .State -}} | ||
{{ if and (ne $cfg.Host "") (eq $cfg.TLSTermination "reencrypt") -}} | ||
{{generateRouteRegexp $cfg.Host $cfg.Path $cfg.IsWildcard}} {{$idx}} | ||
{{ end -}} | ||
{{ end -}} | ||
{{ end -}}{{/* end reencrypt map template */}} | ||
|
||
{{/* | ||
cert_config.map: contains a mapping of <cert-file> -> example.org | ||
This map is used to present the appropriate cert | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, I was just merging in these changes into my branch and I noticed the map is still called
os_edge_http_be
and notos_edge_reencrypt_be
and it is still being referenced as "os_edge_http_be" in the use backend directives. So this PR needs changes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now done, but github hasn't noticed.