Skip to content

Commit 351aedc

Browse files
committed
Use an annotation to provide a route cookie
Route annotation: router.openshift.io/router.cookie.name can be used to set a cookie name for the route. The cookie must pass regex filter "^[a-zA-Z0-9_-][a-zA-Z0-9_-]*" https://trello.com/c/dZpU26W9 (3) Allow routes to set the cookie names for session stickiness
1 parent 3116aaa commit 351aedc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

images/router/haproxy/conf/haproxy-config.template

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
{{/* cidrListPattern: Match a space separated list of CIDRs; e.g. 192.168.21.23/24 192.10.2.12 */}}
2323
{{- $cidrListPattern := printf `(?:%s(?: +%s)*)` $cidrPattern $cidrPattern -}}
2424

25+
{{/* cookie name pattern: */}}
26+
{{- $cookieName := "^[a-zA-Z0-9_-][a-zA-Z0-9_-]*" -}}
27+
2528
{{- $timeSpecRE := "[1-9][0-9]*(us|ms|s|m|h|d)?" }}
2629
global
2730
maxconn {{env "ROUTER_MAX_CONNECTIONS" "20000"}}
@@ -377,7 +380,7 @@ backend be_secure:{{$cfgIdx}}
377380
{{- end }}
378381

379382
{{- if not (isTrue (index $cfg.Annotations "haproxy.router.openshift.io/disable_cookies")) }}
380-
cookie {{$cfg.RoutingKeyName}} insert indirect nocache httponly
383+
cookie {{firstMatch $cookieName (index $cfg.Annotations "router.openshift.io/route.cookie.name") $cfg.RoutingKeyName}} insert indirect nocache httponly
381384
{{- if and (matchValues (print $cfg.TLSTermination) "edge" "reencrypt") (ne $cfg.InsecureEdgeTerminationPolicy "Allow") }} secure
382385
{{- end }}
383386
{{- end }}{{/* end disable cookies check */}}

0 commit comments

Comments
 (0)