Skip to content

net/haproxy: support for cookie-based persistence#680

Merged
fraenki merged 3 commits intoopnsense:masterfrom
fraenki:haproxy_270_plus
May 19, 2018
Merged

net/haproxy: support for cookie-based persistence#680
fraenki merged 3 commits intoopnsense:masterfrom
fraenki:haproxy_270_plus

Conversation

@fraenki
Copy link
Copy Markdown
Member

@fraenki fraenki commented May 19, 2018

This addition makes it pretty easy to configure cookie-based persistence. A new setting was added to the "Edit Backend Pool" configuration page:

cookie-persistence

When enabling cookie-based persistence, the following HAProxy options will be added or changed:

backend example_backend
     # stickiness
     stick-table type ip size 50k expire 30m
-    stick on src
+    cookie SRVCOOKIE prefix
     # tuning options
     timeout connect 30s
     timeout server 30s
-    server websrv1 10.0.0.1:80 check inter 1000 
+    server websrv1 10.0.0.1:80 check inter 1000  cookie 5aff65dd69e5e163736656

frontend example_frontend
     default_backend example_backend
+    # remove quotes from persistence cookie
+    http-request replace-header Cookie '^(.*?; )?(SRVCOOKIE=)"([^;"]*)"(;.*)?$' \1\2\3\4

The cookie value is derived from each server's unique ID. This value is automatically generated by OPNsense and it is guaranteed to never change, unless the server is removed from the GUI.

When using cookie-based persistence, the Balancing Algorithm should be changed from default "Source-IP Hash" to "Round Robin".

@fraenki fraenki added the feature Adding new functionality label May 19, 2018
@fraenki fraenki self-assigned this May 19, 2018
@fraenki fraenki mentioned this pull request May 19, 2018
@fraenki fraenki merged commit 1ccf276 into opnsense:master May 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Adding new functionality

Development

Successfully merging this pull request may close these issues.

1 participant