Configure cookie in the backend server

Last Updated: Sep 14, 2017

Server Load Balancer provides session persistence function. With session persistence enabled, Server Load Balancer can distribute requests from the same client to the same backend server during the session period. For layer-7 listeners, session persistence is based on cookies. If you choose the Rewrite Cookie method, you have to configure the cookie in the backend server.

Follow the instructions in this section to set cookies in the backend server.

Apache

  1. Open the httpd.conf file and ensure that the following line is not commented.

    LoadModule usertrack_module modules/mod_usertrack.so

  2. Add the following configurations in the VirtualHost file.

    1. CookieName name
    2. CookieExpires "1 days"
    3. CookieStyle Cookie
    4. CookieTracking on

Nginx

Configure the configuration file as follows.

  1. server {
  2. listen 8080;
  3. server_name wqwq.example.com;
  4. location / {
  5. add_header Set-Cookie name=xxxx;
  6. root html;
  7. index index.html index.htm;
  8. }
  9. }

Lighttpd

Configure the configuration file as follows.

  1. server.modules = ( "mod_setenv" )
  2. $HTTP["host"] == "test.example.com" {
  3. server.document-root = "/var/www/html/"
  4. setenv.add-response-header = ( "Set-Cookie" => "name=XXXXXX" )
  5. }
Thank you! We've received your feedback.