Nginx

Setup Munin on CentOS 7 with nginx

Munin provides web interface showing graphs about your server's load average, memory usage, CPU usage, MySQL throughput, eth0 traffic, etc. Although it lets you monitor more than one server, this article will discuss the monitoring of the system where it is installed. The following steps are tested running on my Linode server running Centos 7 64-bit. It is assumed that nginx is already installed in your system. If not, please follow this guide.

Using Pagespeed with Nginx

Pagespeed is a quick way to optimize your site following web best practices. It is available as a module for Apache and Nginx. Installing this module in Apache is easy as:


sudo yum install at # if you do not already have 'at' installed
sudo rpm -U mod-pagespeed-*.rpm

To install Nginx, we need to compile the Nginx source in order to include Pagespeed module (please see this article for instructions). For Nginx configuration, please follow this guide.

Setup ECC SSL for Nginx to satisfty Cloudflare Full SSL mode

Cloudflare's Full SSL mode encrypts the connection between your website visitors and CloudFlare also from CloudFlare to your server. This mode requires SSL certificate on your server. In this tutorial will show how to create SSL certificate on server and configure Nginx for SSL.

The following procedures are tested on my Linode server running Centos 7 64-bit Linux distribution.

Setup Nginx as web server and as reverse proxy for Apache with Virtualmin support

We know that Nginx is more faster than Apache and most of us prefer to replace Apache with Nginx as their web server. Nginx is known to serve faster static content and run with less RAM. As of this writing, Virtualmin supports Apache as its web server. To take advantage of Nginx, we will install it as reverse proxy for Apache and continue using Virtualmin to manage your domains (Note: this article will assume that the Nginx and Apache are running on same server).

Methods to disable Nginx cache when user is authenticated in Drupal

There are some cases we only need Nginx cache enabled for anonymous users. I can show two ways on how to disable Nginx cache when user is authenticated and enable it for anonymous users in Drupal.

Method 1: Using Cookie

This method invloves Drupal custom module to set an identifier in Cookie that a user is authenticated.

The custom module uses hook_user_login() to set "nocache=1" in Cookie if user is logged in and hook_user_logout() to set "nocache=0" if user is logged out. The codes are as follows (you can download the custom module below this article):

How to setup Pagespeed module in Nginx using rpm or yum on CentOS 7

Adding Pagespeed module in Apache is very easy with package manager:


sudo yum install at # if you do not already have 'at' installed
sudo rpm -U mod-pagespeed-*.rpm

... but if we want to add Pagespeed module in Nginx, first thing we think of is compiling its source along with the Pagespeed module. What if Nginx is installed in our server from yum or rpm? The process we need is to repackage RPM and that is what this tutorial will show.

Solution to NGINX upstream servers HTTP keepalive enabled serving wrong URL and content

With HTTP keepalive enabled in NGINX upstream servers reduces latency thus improves performance and it reduces the possibility that the NGINX runs out of ephemeral ports. Following the suggestion given by NGINX doc that the proxy_http_version directive should be set to "1.1" and the "Connection" header field should be cleared: