gb
  English
Phone:  +1 (217) 636-4164
Skype:  onegbits
  1. Home
  2. Blog
  3. How To Configure Nginx With SSL

How To Configure Nginx With SSL

How To Configure Nginx With SSL

24

Sep, 16

58

How To Configure Nginx With SSL

How To Configure Nginx With SSL

How To Configure Nginx With SSL. SSL (Secure Sockets Layer) is the standard security technology for establishing an encrypted link between a web server and a browser. This link ensures that all data passed between the web server and browsers remain private and integral. SSL is an industry standard and is used by millions of websites in the protection of their online transactions with their customers. TLS, or transport layer security, and its predecessor SSL, which stands for secure sockets layer, are web protocols used to wrap normal traffic in a protected, encrypted wrapper. Using this technology, servers can send traffic safely between the server and the client without the concern that the messages will be intercepted and read by an outside party. The certificate system also assists users in verifying the identity of the sites that they are connecting with. To Configure Nginx With SSL 3 option is Required:
  1. Installed nginx webserver on Linux VPS or Dedicated Server
  2. Domain Name
  3. SSL Certificate

Create a directory

mkdir -p /etc/nginx/ssl/1gbits.com

Generating Your SSL Key and CSR

Prior to purchasing a cert, you need to generate a private key, and a CSR file (Certificate Signing Request). You’ll be asked for the content of the CSR file when ordering the certificate. For Common Name enter your intended domain name without ‘www’ i.e. 1gbits.com. If it’s a Wildcard SSL, use *.1gbits.com.
openssl req -nodes -newkey rsa:2048 -keyout 1gbits.com.key -out 1gbits.com.csr

Create a certificate bundle

After purchase the certificate, You’ll eventually get an email with your SSL Certificate. It contains a zip file with the following:
  • AddTrustExternalCARoot.crt
  • COMODORSAAddTrustCA.crt
  • COMODORSADomainValidationSecureServerCA.crt
  • 1gbits_com.crt
cat 1gbits_com.crt AddTrustExternalCARoot.crt COMODORSADomainValidationSecureServerCA.crt
COMODORSAAddTrustCA.crt >> ssl-bundle.crt Once create a certificate bundle you can move it to your Nginx SSL directory.
mv ssl-bundle.crt /etc/nginx/ssl/1gbits.com/

Configure the Certificate for nginx

Go to nginx virtual host configuration, using SSL with nginx requires a modification to the listen directive and three ssl-related directives as shown in the following examples:
nano /etc/nginx/conf.d/ssl.conf
server {
   listen 443 ssl spdy;
   server_name www.idroot.net idroot.net;
   root /var/www/idroot.net/public_html;
   index index.php index.html index.htm;
   server_tokens off;

   #SSL CONF
   ssl on;
   ssl_certificate /etc/nginx/ssl/idroot.net/ssl-bundle.crt;
   ssl_certificate_key /etc/nginx/ssl/idroot.net/idroid.us.key;


   #SSL
   ssl_session_cache shared:SSL:20m;
   ssl_session_timeout 10m;

   ssl_prefer_server_ciphers On;
   ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
   ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;

   ssl_stapling on;
   ssl_stapling_verify on;
   resolver 8.8.8.8 8.8.4.4 valid=300s;
   resolver_timeout 10s;

   # permalink
   location / {
      try_files $uri $uri/ /index.php?$args;
   }

   # php-script handler
   location ~ \.php$ {
      fastcgi_index index.php;
      fastcgi_pass 127.0.0.1:9000;
      root    /var/www/idroot.net/public_html;
      fastcgi_param SCRIPT_FILENAME /var/www/idroot.net/public_html$fastcgi_script_name;
      include /etc/nginx/fastcgi_params;
   }

location  ~ /\.ht {
               deny  all;
           }
    }

Redirect HTTP Virtual Hosts to HTTPS

return 301 https://1gbits.com$request_uri;

Restart/reload nginx

/etc/init.d/nginx restart
Congratulation’s! You have successfully installed Nginx with SSl.
Leave A Comment
We are with you

24 X 7 X 365

+1 (217) 636-4164

©2017 1Gbits. All rights reserved