Ecommerce Shopify WordPress Discussion

How to deal with wordpress nonces when running on multiple servers behind a Load Balancer?

We have a wordpress site (not multi-site) running on a distributed system, where two (or more) servers sit behind a load balancer. We've routed most (not all) requests to /wp-admin/ to hit a specific server (call it server1) and any front-end traffic can hit any server. We also copy all files inside /public_html/ from server1 to the other servers, so we don't have to use NFS or similar. We noticed that when server1 creates a request using wp_create_nonce and then server2 tries to verify it using wp_verify_nonce the validation fails. The example we have was with wp-cron.php initiating an async request hitting the application, which always fails if server2 deals with the request and never fails if server1 deals with it. So when server1 calls /wp-admin/admin-ajax.php?action=wc_whatever_action&nonce=12345, if the request goes into server1 it works fine, but if it hits server2, it fails with 403. If we were to use Sticky Sessions, this issue would probably go away, but on Nginx Load Balancers, this only comes with Nginx Plus at a significant cost and alternatives like the CloudFlare Load Balancer doesn't quite meet our needs, so I'm exploring different solutions. All salts in wp-config.php are the same across all servers. I've seen a couple of plugins around PHP Sessions where they store the $_SESSION in the SQL/Redis, but I'm not too sure those will work, as i don't think WordPress acutally uses Sessions in core.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.