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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

WebStorm Mac version
Useful JavaScript development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Notepad++7.3.1
Easy-to-use and free code editor
