Nginx SSL Configuration

Overview

Nginx is becoming one of the more popular event driven web servers. As of October 2014, it is currently used amongst the top 20% of the most busiest websites today Netcraft. Setting up SSL should not be a daunting task, so I created a default SSL configuration (from Raymii.org) and Nodejs config here.

You can setup multiple sub domains in the same server config:

server_namelink
1
server_name    abc-dev.sample.com abc.sample.com;

Redirect all HTTP to HTTP requests permanently (301):

HTTP redirectlink
1
2
3
if ($scheme != "https") {
rewrite ^ https://$server_name$request_uri? permanent;
}

Also, redirect any unsupported client browsers:

browser redirectlink
1
2
3
4
## redirect ie8 and lower
if ($http_user_agent ~ "MSIE\s([1-8])\.") {
rewrite ^ /unsupported break;
}

Source.

Best,
Chris