A web tier can keep serving requests during maintenance only if another server is ready to accept them. An active-active Nginx setup with PCS keeps a web-server instance running on each eligible Pacemaker node.

Pacemaker controls the packaged nginx.service through a systemd clone, starting and monitoring an instance on each node. Each server uses its own address, while an external load balancer distributes requests and removes unhealthy backends. The clone does not provide client routing or a shared virtual IP.

The starting point is a quorate cluster with working fencing and Nginx installed on every node. The same site configuration, certificates and content must already be present on each server because cloning does not replicate them. Stateful applications behind Nginx still need their own concurrency and data-consistency design.

Steps to set up Nginx active-active with PCS:

  1. Confirm all intended Nginx nodes are online in a quorate cluster.
    $ sudo pcs status
    Cluster name: clustername
    Cluster Summary:
      * Stack: corosync (Pacemaker is running)
      * Current DC: node-01 (version 3.0.1-3.0.1) - partition with quorum
    ##### snipped #####
    Node List:
      * Online: [ node-01 node-02 ]
    
    Full List of Resources:
      * fence-ipmi-node-01	(stonith:fence_ipmilan):	 Started node-01
      * fence-ipmi-node-02	(stonith:fence_ipmilan):	 Started node-02
    ##### snipped #####

    The node names here are node-01 and node-02. Cluster commands run once on either node unless a step names a particular node. Existing fencing must be configured and tested before adding the web service.

  2. Test the Nginx configuration on every cluster node.
    $ sudo nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful

    A successful syntax test is required on each node before Pacemaker starts the service. Listening addresses must exist on the local node, and the intended HTTP ports must be reachable from the load balancer.

  3. Disable standalone Nginx startup on every node during the maintenance window.

    The next command stops Nginx immediately, interrupting requests until Pacemaker starts the clone. Automatic startup at boot must remain disabled so systemd and Pacemaker do not compete for ownership. If setup is abandoned before resource creation, sudo systemctl enable --now nginx restores standalone service on each node.

    $ sudo systemctl disable --now nginx
  4. Create the Nginx service as a cloned Pacemaker resource.

    Resource creation starts Nginx and binds its configured listening ports. Only a service that can safely run on all nodes belongs in this clone.

    $ sudo pcs resource create nginx_service systemd:nginx op monitor interval=30s clone --future --wait=60

    systemd:nginx manages nginx.service. The clone is named nginx_service-clone and defaults to one instance per eligible node. The --future option selects the newer PCS resource-creation syntax. The --wait=60 option waits up to 60 seconds for startup. The monitor checks the service state; it does not replace an HTTP or application health check.

  5. Confirm the clone has started on both nodes.
    $ sudo pcs status resources
      * Clone Set: nginx_service-clone [nginx_service]:
        * Started: [ node-01 node-02 ]

    A stopped instance, failed action or timeout needs investigation before traffic is sent to that backend.

  6. Put node-01 into standby from node-02 for a planned outage test.

    Standby stops or relocates every cluster resource on node-01, including services unrelated to Nginx. The surviving node needs enough capacity, and active connections to node-01 may be interrupted. This tests a graceful withdrawal, not abrupt host loss or fencing.

    $ sudo pcs node standby node-01 --wait=60
    Waiting for the cluster to apply configuration changes (timeout: 60 seconds)...
  7. Confirm only node-02 hosts an active Nginx clone instance.
    $ sudo pcs status resources
      * Clone Set: nginx_service-clone [nginx_service]:
        * Started: [ node-02 ]
        * Stopped: [ node-01 ]
  8. Request the site from the surviving node.
    $ curl -fsSI http://node-02/
    HTTP/1.1 200 OK
    ##### snipped #####

    The surviving instance remains available without a replacement instance being started there. A load balancer with HTTP health checks can exclude node-01 while it is stopped; direct node requests alone do not prove the client-facing route.

  9. Return node-01 to service from node-02.
    $ sudo pcs node unstandby node-01 --wait=60
    Waiting for the cluster to apply configuration changes (timeout: 60 seconds)...
  10. Confirm both Nginx clone instances are running again.
    $ sudo pcs status resources
      * Clone Set: nginx_service-clone [nginx_service]:
        * Started: [ node-01 node-02 ]
  11. Verify both restored nodes still serve the site.
    $ curl -fsSI http://node-01/ http://node-02/
    HTTP/1.1 200 OK
    ##### snipped #####
    HTTP/1.1 200 OK
    ##### snipped #####

    The request runs from node-02 using resolvable node names. The site shown listens on port 80 and returns 200 at /. Both responses must match the intended site; a default welcome page does not prove a different application is working. For a name-based virtual host, the request also needs the site's Host header; HTTPS requires its matching hostname and certificate.

Share this guide