Setup Multiple Mediawiki Servers Behind AWS ELB Login Session Stickiness

From Bonus Bits
Jump to: navigation, search

Purpose

This article gives the steps to setup application session state stickiness with multiple Mediawiki web server AWS EC2 instances behind an AWS ELB (Elastic Load Balancer). This is so when you login to a specific Mediawiki instance the load balancer knows to send you back to that same instance based on your session cookie from you browser.


Prerequisites

  • Mediawiki AWS EC2 instances
  • AWS ELB


Enable Private IP Tracking

  1. Add the following to your LocalSettings.php. This is so all Mediawiki doesn't see all users as coming from the ELB.
    $wgUsedPrivateIPs = true;
    


Discover Session Cookie Name

Found out the name of your Mediawiki session cookie name. I used a Chrome plugin named Cookie Inspector. I think the default is sitename_mediawiki_mw__session

  1. Install the Chrome plugin
  2. Browse to your Mediawiki site Main page
  3. Login
  4. Open Chrome Developer Tools
  5. Select Cookies from the top menu
    1. You may have to click the >> to see the menu item
  6. Look for a cookie name ending in mw__session
    1. For example bonusbits_mediawiki_mw__session


Set ELB Application Stickiness Session

  1. Open AWS Web Console (or do with AWS CLI)
  2. Select EC2
  3. Select Load Balancers
  4. Select the correct ELB
  5. Browse to Description | Port Configuration
  6. Select Edit next to listening port
    1. Usually 80 or 443
  7. On the Edit Stickiness configuration page select Enable Application Generated Cookie Stickiness
  8. Enter the following cookie name
    bonusbits_mediawiki_mw__session
  9. Test


Setup Shared Session Location

I think a shared session location will be needed so this works correctly... need to research and do more testing to be sure. The above works, but I have a feeling it's not 100%.