Application routing based on session id in URL

Hi,

My application will be hit first with a URL like .../app/WebObjects/App.woa. The applications responds by redirecting the user to a single-sign-on (SSO) login page and providing a callback URL. Then the user authenticates and then he is redirected using the callback URL that looks like .../wa/ssoCallback?wosid=.
After that the URLs into the application will always have a session id. We have two types of URLs: direct actions and component actions:

  • direct actions: .../wa/actionName?wosid=<sessionid>
  • component actions: .../wo/<sessionid>/...

I want to be able to parse sessionid and use that as a hash to select the backend pod to route the request.

In nginx theoretically you can have a map in the http block to parse the session id into a variable and then use that in the upstream block as a hash to select the backend pod:

http {
    map $request_uri $session_id {
        ~*/wo/(?<id>[^./]+)/      $id;
        ~*[?&]wosid=(?<id>[^&]+) $id;
        default                   $request_uri;
    }

    # existing upstream block (managed by ingress-nginx)
    # the $session_id variable is referenced here to ensure
    # requests with the same session ID always route to the
    # same pod
    upstream myapp_backend {
        hash $session_id consistent;

        server 10.0.0.1:8080;
        server 10.0.0.2:8080;
        server 10.0.0.3:8080;
    }

    server {
        listen 8080;
        server_name dev.example.com;

        location /app/WebObjects/MyApp {
            ...
        }
    }
}

Our goal is to be able to have multiple tabs open into the application and every tab connected to a separate session.

We are trying to avoid using cookies sent to the browser and then rely on the browser sending them back to us in every request for session affinity mainly because cookies are shared across tabs in the browser.

It would be okay to have a cookie solution that is "injected" in the server side after parsing the session id from the URL (for direct actions and component actions). Then this cookie would be used for routing to a pod in the backend.

Our applications are deployed using EKS. We are being told that our current ingress controller for EKS, ingress-nginx, went EOL in March and is to be replaced with traefik.

How can I do something like this with traefik?

Thank you

Ricardo Parada

Not sure such an extraction of sid can work with Traefik. Have you tried a simple sticky session via cookie?