Example of how to configure nginx to implement SSL

Example of how to configure nginx to implement SSL

Environmental Description

Server system: Ubuntu 18.04 64-bit
nginx: 1.14

This article mainly records the steps to configure https, and does not introduce the details of applying for a CA certificate.

There are free SSL certificates here: https://cloud.tencent.com/act/pro/ssl

I have a domain name of West Digital and applied for a certificate in Tencent Cloud

After applying for the certificate and issuing it, download the certificate to your local computer first.

1. Install nginx

$ apt-get update // Update software $ apt-get install nginx // Install nginx

2. Configure CA certificate

2.1 The installation directory of nginx is /etc/nginx/. Enter the directory, add the cert folder, and upload the two files just downloaded to the cert folder.

2.2 Add a new configuration file blog.conf in the /etc/nginx/conf.d/ folder. The name is arbitrary. Nginx will read all configuration files in the conf.d/ folder.

2.3 Copy the following configuration information into the blog.conf file

server {
 listen 443;
 server_name xiaoxina.cc; //your domain name ssl on;
 root /var/lib/jenkins/workspace/blog; // Your website source directory index index.html index.htm;
 ssl_certificate /etc/nginx/cert/xiaoxina.cc.crt; // Certificate address ssl_certificate_key /etc/nginx/cert/xiaoxina.cc.key; // Certificate address ssl_session_timeout 10m;
 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
 ssl_prefer_server_ciphers on;
 ssl_session_cache builtin:1000 shared:SSL:10m;
 ssl_buffer_size 1400;
 add_header Strict-Transport-Security max-age=15768000;
 ssl_stapling on;
 ssl_stapling_verify on;
 location / {
  index index.html index.htm;
 }
}

server {
 listen 80;
 server_name xiaoxina.cc; // your domain name rewrite ^(.*)$ https://$host$1 permanent;
}

After the configuration is complete, check whether the nginx configuration file is available. If successful appears, it means the configuration is correct.

$ nginx -t

After the configuration is correct, reload the configuration file to make the configuration take effect:

$ service nginx reload

This is the end of this article about the example of configuring nginx ssl to implement https. For more relevant content about nginx implementing https, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Introduction to SSL certificate installation and deployment steps under Nginx
  • Solution to Nginx SSL certificate configuration error
  • Nginx domain name SSL certificate configuration (website http upgraded to https)
  • Nginx configuration SSL and WSS steps introduction

<<:  Simple example of adding and removing HTML nodes

>>:  MySQL 8.0.23 installation and configuration method graphic tutorial under win10

Recommend

Nginx URL rewriting mechanism principle and usage examples

URL rewriting helps determine the preferred domai...

Various ways to achieve the hollowing effect of CSS3 mask layer

This article introduces 4 methods to achieve mask...

MySql 5.7.20 installation and configuration of data and my.ini files

1. First download from the official website of My...

Tips for organizing strings in Linux

In Linux operations, we often replace and count s...

HTML simple web form creation example introduction

<input> is used to collect user information ...

Processing ideas for decrypting WeChat applet packages on PC in node.js

Table of contents Where is the source code of the...

CentOS 7.x deployment of master and slave DNS servers

1. Preparation Example: Two machines: 192.168.219...

Teach you how to use MySQL8 recursive method

I have previously written an article about recurs...

CSS code to distinguish ie8/ie9/ie10/ie11 chrome firefox

Website compatibility debugging is really annoyin...

Docker View JVM Memory Usage

1. Enter the host machine of the docker container...

Example of using Vue built-in component keep-alive

Table of contents 1. Usage of keep-alive Example ...