Wednesday, February 25, 2015

HTTPS in NGINX

Been reading about NGINX. When you install and run NGINX, its operation is controlled by a configuration file called nginx.conf. This file has a tree like structure that defines contexts with the help of directives. The http context is a misnomer. It leads you to think that HTTP connection settings are governed by the directives defined in it. But guess what, it can also be used to control HTTPS connections. You just have to specify HTTPS directives in it.

http {
server {
listen 80;
listen 443 ssl;
server_name www.helloworldexample.com;
ssl_certificate www.helloworldexample.com.crt;
ssl_certificate_key www.helloworldexample.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
...
}
}

Using this configuration for the http context will enable your NGINX server to handle both HTTP and HTTPS requests.

No comments:

Post a Comment