0

We have an existing SPA application running on server #1. We built out a Wordpress site hosted on a Kinsta server (server #2). Marketing wants to launch the new site and direct 50% of traffic to it while directing 50% of traffic to the old SPA.

My solution: I set up a load balancer using Cloudflare to split the traffic between the two servers equally. This works great. I then needed to have server #1 (existing Nginx configured as reverse-proxy) handle all requests for /wp-* and send them to server #2.

My current Nginx location block

location ~* /wp-(.*)$ {
    proxy_pass         https://{{server #2 ip address}}/wp-$1$is_args$args;
    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
  }

The problem: While this somewhat works, many of the requested files return a 404 while some others load fine. Here are some example urls and their status codes.

https://{{domainname}}/wp-content/plugins/wordpress-seo/css/dist/wpseo-dismissible-1500.css 200 https://{{domainname}}/wp-content/plugins/elementor/assets/js/admin.min.js 404

I've checked that both of these files exist on server #2 which they do.

Can anyone recommend an Nginx config that will work for this problem? I toyed around with using rewrite and a 302 (didn't try 301) but that didn't solve the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.