search

How to install Nginx SSL certificate

Mar 30, 2019 pm 04:12 PM
nginx

All sites running with SSL use the https protocol on the default port 443. SSL provides secure data communication by encrypting data between the server and client. This article will introduce configuring SSL in nginx server.

How to install Nginx SSL certificate

Step 1: Install nginx web server

We assume that nginx is already installed on the system, but if it is not installed yet, Please use the following commands to install.

$ sudo apt-get install nginx

Step 2: Obtain an SSL Certificate

For creating an SSL certificate, the first requirement is to create a private key and CSR. A CSR is a file that contains all the details about a domain, including the public key. First create a directory where you create the CSR and key.

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

Now create the CSR and key files using the following commands. Change the file names example.com.key and example.com.csr according to your domain name. This command will ask for information about your domain.

# openssl req -new -newkey rsa:2048 -nodes -keyoutexample.com.key-outexample.com.csr

After creating the CSR, request an SSL certificate from any certificate provider (such as geotrust, comodo, digicert or godaddy, etc.). After obtaining the certificate from the CA, merge the primary and intermediate certificate files into one file.

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

Step 3: Set up virtual host with SSL

Let us edit the nginx configuration file /etc/nginx/conf.d/example.com.conf and add the following value.

# 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;
}

Step 4: Restart nginx

Finally, restart the nginx server for the changes to take effect.

# service nginx restart

The above is the detailed content of How to install Nginx SSL certificate. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment