Install SSL on Nginx Webserver with HTTP and HTTPS Server
By Shay Anderson on November 2013
Nginx can easily be setup to serve both HTTP and HTTPS requests for the same server.
First, create a directory to store your SSL certificate and key: # mkdir /etc/nginx/sslNow copy your SSL certificate and key to the new directory.
Note: if you don’t have an SSL certificate and key you can create your own using a command like: # openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/example.com.key -out /etc/nginx/ssl/example.com.crt
To set the SSL edit your nginx server config file where your HTTP server is located (for example, it might be /etc/nginx/conf.d/default.conf) and add your SSL certificate and key locations: server {
# HTTP server
listen 80;
# HTTPS server
listen 443 ssl;
server_name example.com www.example.com;
# add SSL locations
ssl_certificate /etc/nginx/ssl/example.com.crt;
ssl_certificate_key /etc/nginx/ssl/example.com.key;
root /var/www/example.com/html;
index index.htm;
…
}
Finally, reload the nginx config file: service nginx reload
http://www.shayanderson.com/linux/install-ssl-on-nginx-webserver-with-http-and-https-server.htm