We can run both the apps by configuring the virtual host files. You can find the settings i used for Apache and Nginx below. Make sure you have both of your apps ready by going over the prerequisites. In my case the wordpress blog is running in PHP while the rest of the site is running on NodeJS.

Apache

Prerequisites

  • Apache is installed

  • Proxy module for Apache is installed

  • PHP is installed

  • NodeJS app is running by itself on port 3000

  • PHP is installed

<Virtualhost>
  ServerName craftypixels.com
  ProxyPreserveHost on 
  ProxyPass /blog ! 
  ProxyPass / http://localhost:3000/ 
  ProxyPassReverse / http://localhost:3000/ 
  alias /blog /var/www/craftypixels/blog

  DocumentRoot /var/www/craftypixels/blog/ 
  Options -Indexes
</Virtualhost>

Nginx

Prerequisites

  • Nginx  1.11.* is installed

  • PHP is installed and socket file is located at /php7.0-fpm.sock

  • PHP app is placed at /var/www/craftypixels/blog/

  • NodeJS app is running by itself on port 3000

server {
    listen 80;
    server_name craftypixels.com;
    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

location @blog {
  rewrite ^/blog(.*) /blog/index.php?q=$1;
}
location /blog {
    index index.php;
    try_files $uri $uri/ @blog;
    alias /var/www/craftypixels/blog;

     location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }

} }