Bypass Varnish for Large WP STAGING Remote Sync Backups (Nginx Vhost Fix)

The release of Remote Sync is a milestone for WP STAGING. By allowing users to synchronize WordPress sites across different servers, we are tackling one of the most highly demanded features in our history.

However, moving massive amounts of data – sometimes exceeding 30 GB – introduces unique server-side challenges. One common hurdle is Varnish Cache. While Varnish is excellent for speeding up your site, it can act as a “chokepoint” during heavy data transfers.

The Problem: Varnish Buffer Limits

When Remote Sync initiates, it creates a compressed backup file on the source site and downloads it to the destination. If Varnish is active on your server, it sits between Nginx and your application.

Varnish often has a default limit for object sizes (sometimes as low as 512MB). When the WP STAGING backup file exceeds this limit, Varnish terminates the connection, causing the sync to fail. Even if you “exclude” the path in a control panel like CloudPanel, Nginx still proxies the request through Varnish, leading to the same bottleneck.

The Solution: Bypassing Varnish via Vhost

To ensure a stable transfer of large backup files, you must tell Nginx to bypass Varnish entirely for the WP STAGING backup directory. This is done by editing your site’s Virtual Host (vhost) configuration.

1. Identify the Backup Path

The default directory where WP STAGING stores temporary sync files is: /wp-content/uploads/wp-staging/backups/

2. Update your Nginx Configuration

Add the following snippet to your Nginx vhost file. This directive tells the server to send requests for this specific folder directly to the backend (usually on port 8080), skipping the Varnish service (usually on port 6081) and disabling buffering.

Nginx

# Large WP STAGING backup files - BYPASS VARNISH
location ^~ /wp-content/uploads/wp-staging/backups/ {
    proxy_pass http://127.0.0.1:8080;
    proxy_buffering off;
    proxy_request_buffering off;
    proxy_set_header Host              $host;
    proxy_set_header X-Real-IP         $remote_addr;
    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    add_header Cache-Control "private, no-store" always;
}

Why this works

  • proxy_pass to 8080: By pointing directly to the backend port, we avoid the Varnish layer entirely.
  • proxy_buffering off: This prevents Nginx from trying to “save” the file in its own cache before serving it, which is essential for 10GB+ files.
  • ^~ Modifier: This ensures this rule takes priority over other regular expression matches, making sure the exclusion is strictly enforced.

Alternative: Temporary Disabling

If you are uncomfortable editing vhost files, you can temporarily disable Varnish on your server before starting a large Remote Sync and re-enable it once the “Restore” phase is complete. However, the vhost method above is the recommended “set and forget” solution.

Updated on February 9, 2026