Close Menu
    Facebook X (Twitter) Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook X (Twitter) Instagram
    TecAdmin
    You are at:Home»Linux Commands»How to Install Nginx SSL Certificate

    How to Install Nginx SSL Certificate

    By RahulMarch 9, 20162 Mins Read

    All the sites running with SSL are used https protocol on default port 443. SSL provides secure data communication by encrypting data between server and client. This article will help you to configure SSL in Nginx server. For this example we are using a self signed certificate.

    Step 1 – Install Nginx Web Server

    We are assuming that you already have Nginx installed on your system but in case you don’t have installed it already, Use following command to install it.

    $ sudo apt-get install nginx
    

    Step 2 – Get SSL Certificate

    For creating SSL certificate, the first requirement is to create private key and CSR. A CSR is a file which have all details about domain including a public key. first create a directory where to create csr and key.

    # mkdir /etc/nginx/ssl/
    # cd /etc/nginx/ssl/
    

    Now create CSR and key file with following command. Change name of files example.com.key and example.com.csr as per your domains. This command will ask for enter information about your domain. Read more about creating CSR.

    # openssl req -new -newkey rsa:2048 -nodes -keyout example.com.key -out example.com.csr
    

    After creating CSR, Request an SSL certificate from any certificate providers like Geotrust, Comodo, Digicert or GoDaddy etc. After getting certificate from CA, combine your primary certificate and intermediate certificate file in single file.

    # cat example.com.crt DigiCertCA.crt >> example.com.pem
    

    Step 3: Setup VirtualHost with SSL

    Let’s edit Nginx configuration file /etc/nginx/conf.d/example.com.conf and add the following values.

    # HTTPS Server Block
    
    server {
    
        listen   443;
        server_name example.com www.example.com;
    
        root /var/www/xyz.com/httpdocs;
        index index.html index.htm;
    
        ssl on;
        ssl_certificate /etc/nginx/ssl/example.com.pem;
        ssl_certificate_key /etc/nginx/ssl/example.com.key;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
        ssl_prefer_server_ciphers on;
    }
    

    Step4 – Restart NGINX

    Finally restart nginx server for changes takes effect.

    # service nginx restart
    

    nginx SSL
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Disable ETag in NGINX

    How to Disable ETag in NGINX

    How to Ignore SSL Certificate Check with Wget

    How to Ignore SSL Certificate Check with Curl

    View 1 Comment

    1 Comment

    1. Nguyen on August 8, 2017 11:17 pm

      Hello, how i can install Godaddy SSL on nginx for every subdomain like : http://www.example.com, sub1.example.com

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to Change Port in Next.Js
    • Ubuntu 24.04 LTS: The Future of Open-Source Excellence
    • How to Execute Linux Commands in Python
    • Creating MySQL User with GRANT OPTION
    • Where to find crontab (cron) logs in Ubuntu & Debian
    Facebook X (Twitter) Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.