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.

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;
        }

} }

What are Webservers?

A web server is a computer that runs websites. It’s a computer program that distributes web pages as they are requested by a browser. The basic objective of the web server is to store, process and deliver web pages to the users. This intercommunication is done using Hypertext Transfer Protocol (HTTP) and Hypertext Transfer Protocol Secure (HTTPS). Here are some examples of some leading Web servers.

  1. Apache Server
  2. Microsoft Internet Information Services IIS
  3. Lighttpd
  4. Nginx Web Server
  5. Sun Java System Web Server
  6. Tomcat Server

What is Apache or Apache2?

Apache is the most widely used web server software. Developed and maintained by Apache Software Foundation, Apache is an open source software available for free. It runs on 67% of all web servers in the world. It is fast, reliable, and secure. It can be highly customized to meet the needs of many different environments by using extensions and modules. Most WordPress hosting providers use Apache as their web server software.

What is Nginx?

NGINX is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. In addition to its HTTP server capabilities, NGINX can also function as a proxy server for email (IMAP, POP3, and SMTP) and a reverse proxy and load balancer for HTTP, TCP, and UDP servers.