Nginx routing script for NodeJS and Wordpress
- by Nilay Parikh
We are moving blogs and site from wordpress to nodejs and ready to move into production. However I'm not able to figure it out how to implement routing from front server (Nginx) to NodeJS (prefered web instance) and if data not synced yet into NodeJS website than (404 will throw by NodeJS) fall back to (using reverse proxy) to Wordpress and serve page, during the transformation period.
Q1. Is the approach good for the scenario, or anyone can suggest better approach?
Q2. Should NodeJS treat itself as Reverse proxy (using bouncy : https://github.com/substack/bouncy or similar package) in event of fall back or shoud stick with Nginx to do so using fastcgi approch.
Both NodeJS and Wordpress are on single server only,
In first scenario,
/if resource available than serve directly
User -> Nginx -> NodeJS (8080)
\if resource not available then reverse query wordpress and serve content
second scenario,
/if resource available than serve directly
User -> Nginx -> NodeJS (8080)
\if resource not available then 404 to Nginx and Nginx script fallback to Wordpress (FastCGI PHP)
Later we have plan to phase out Wordpress and PHP from the server environment completely.
I'd like to see any examples of Nginx or Varnish scripts and/or NodeJS scripts if you have for me to refer.
Thanks.