Lucee, Nginx, Round Robin and the best setup solution

I am trying to get Lucee and Load balancing working but with little success.

I am currently storing my sessions in a database (that works fine) but when I use upstream the session are lost.

Here’s my App.cfc settings for session

  this.sessioncookie.httponly  = true;
  this.sessionTimeout          = createTimeSpan(0,3,0,0);
  this.sessionType             = "cfml";
  this.setDomainCookies        = false;
  this.clientManagement        = false;
  this.setClientCookies        = false;
  this.sessionStorage          = "sstorage";
  this.sessionManagement       = true;

And here is my Nginx code

upstream    lucee_servers {

server {
  root /var/www/html/;
  location ~ \.(cfm|cfml|cfc|jsp|cfr)(.*)$ {
    add_header X-Upstream $upstream_addr always; #so I know which upstream is being used
    set $path_info $request_uri;
    proxy_pass http://lucee_servers;
    proxy_read_timeout 100s;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Tomcat-DocRoot $document_root;
    proxy_set_header X-ModCFML-SharedKey 8DoB0PzqdMn4zo0Y2bq7dzqynbqBVsK0piuNslpNU6982KaiCqVT8X;

Is there anything I am missing?

We also have

this.sessionCluster = true;

This is because without it, it grabs the session from the DB to start with, then doesn’t update the DB with any changes, so when the other instance grabs the session it doesn’t have the latest values.

Thanks for the reply. I can’t seem to get this going with NGINX. The sessions just don’t stick.

I’ll have another play next week to see if I can get it going.

Ah, just re-looked at your original code, you’re not setting cookies… If you set setClientCookies to true it should work, or are you manually setting the cookies in the onSessionStart() function?