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

Sticky cookies #29

Closed
krizhanovsky opened this issue Nov 13, 2014 · 6 comments
Closed

Sticky cookies #29

krizhanovsky opened this issue Nov 13, 2014 · 6 comments

Comments

@krizhanovsky
Copy link
Contributor

Need to implement analog of Nginx sticky module (https://github.com/lusis/nginx-sticky-module) for users identification. However, the module must be able to generate cryptographically safe cookie value depending on the user IP and User-Agent header value, so the server classification logic can identify a user by the cookie value as well as forward his or her requests to the right backend.

@krizhanovsky
Copy link
Contributor Author

See also implementation of simalr functionality in HAProxy.

The Cookies functionality required for intelligent users blocking and load balancing.

@keshonok
Copy link
Contributor

keshonok commented Mar 5, 2015

This issue depends on successful resolution of #47.

@krizhanovsky krizhanovsky added this to the 0.3.0 Proxy Filter milestone Mar 11, 2015
@krizhanovsky
Copy link
Contributor Author

Depending on the configuration Tempesta must be able to forward to do following (the feature should have configuration option to enable/disable the logic below):

  1. if client request hasn't our cookie, then reply to the client w/ 302 status code and the new cookie value
  2. the cookie should be calculated as <timestamp,HMAC(secret, timestamp, User-Agent, ClientIP)>, where is configured value or random number calculated on the system startup
  3. if a request has the cookie, then forward the request to backend

Timestamp must be stored in the client session.

Thus, with the feature enabled backend server behind Tempesta should receive requests only with the sticky cookies.

@krizhanovsky krizhanovsky mentioned this issue Mar 14, 2015
@vdmit11
Copy link
Contributor

vdmit11 commented Mar 14, 2015

A possible bug:

The issue #5 states the requirement:

by list of statically specified URL, Host or backed IP addresses (i.e. each backend server must have it's own list of URLs and/or Host values (or IP addresses instead of DNS names) by which are sent to it)

But if the sticky cookie is enabled and we are routing all HTTP requests to the same server, then we can violate the list of Host/URI rules easily. That sounds like a bug.

Domain-specific and path-specific cookies could solve the issue, but the problem is the current implementation of tfw_sched_http supports extended rules: it allows to specify any header field and choose a comparison function. Cookies can't handle that.

Perhaps the simplest solution is to use domain-specific/path-specific cookies, but drop the support of "extended" rules. The issue #76 implies that the tfw_sched_http should be re-designed to support large sets of rules, so we have to implement an efficient search by URI/host and therefore drop the list-based implementation of these "extended" rules anyway.

@krizhanovsky
Copy link
Contributor Author

But if the sticky cookie is enabled and we are routing all HTTP requests to the same server, then we can violate the list of Host/URI rules easily. That sounds like a bug.

These are different scheduling algorithms. Current issue doesn't require any scheduling adjustments. Only its possible applications for scheduling was mentioned.

keshonok added a commit that referenced this issue Apr 24, 2015
- Switch on several CRYPTO options when Tempesta is configured.
  HMAC and SHA1 are used now for Tempesta sticky cookie (#29).
- Supporting function for implementation of ss_sock_create() (#87).
@krizhanovsky
Copy link
Contributor Author

Merged to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants