Configuring Nginx Plus as a load balancer

This tutorial will walk you through configuring Nginx Plus as a load balancer to direct client requests to a group of PowerServer Web APIs. You will have to configure Nginx Plus as a load balancer and use the sticky cookie to support session persistence. With sticky cookies, the requests from the same user session are always directed to the same PowerServer Web APIs.

Step 1: Install Nginx Plus. Nginx Plus is a commercial product. You will need to purchase it first or apply for a trial version of Nginx Plus.

Step 2: Configure Nginx Plus to direct requests to the PowerServer Web APIs group using the sticky cookie load-balancing method.

  1. Open the nginx.conf file in a text editor.

  2. Add an "http" block that defines the server group.

    • The "listen" directive specifies the port number for the requests. The Web API URL should point to this port number.

    • The "proxy_pass" directive forwards the request to the server group defined in the "upstream" directive, therefore, it should match with the upstream name.

    • The "upstream" directive defines the PowerServer Web APIs group.

      In the following example, the "upstream" block consists of three server configurations; it could consists of more.

      The "upstream" block also consists of the "sticky" directive and defines the cookie name and timeout value. The cookie timeout value must be equal to or greater than the session timeout value (which is 3600 seconds by default). In the following example, the cookie timeout value is set to 1 hour (which is 3600 seconds).

      For more information about the sticky cookie and the other load-balancing methods (such as sticky route and sticky learn), refer to

    The following configuration defines a PowerServer Web APIs group named servergroup which consists of three .NET servers:,, and, and requests made to the URL: http://<server>:8080/ will be redirected to the PowerServer Web APIs group.

    http {
        server {
            listen  8080;
            location / {
               proxy_set_header Host $http_host;
               proxy_pass http://servergroup;
        upstream servergroup {
            sticky cookie srv_id expire=1h path=/;