Home >Operation and Maintenance >Windows Operation and Maintenance >How to install Nginx SSL certificate
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.
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!