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

Echarts implements switching different X-axes in one graph (example code)

Rendering If you want to achieve the effect shown...

Summary of several implementations of returning to the top in HTML pages

Recently, I need to make a back-to-top button whe...

Detailed explanation of Docker usage under CentOS8

1. Installation of Docker under CentOS8 curl http...

Install mysql5.7.13 using RPM in CentOS 7

0. Environment Operating system for this article:...

How to fix the four sides of the table to scroll up, down, left and right

question: When I was doing project statistics rec...

SQL implements LeetCode (180. Continuous numbers)

[LeetCode] 180. Consecutive Numbers Write a SQL q...

Analysis of Linux boot system methods

This article describes how to boot the Linux syst...

Implementation code for operating mysql database in golang

Preface Golang provides the database/sql package ...

Detailed explanation of 7 SSH command usages in Linux that you don’t know

A system administrator may manage multiple server...

How to reset your Linux password if lost

1. The startup menu is to move the cursor to the ...

mysql5.7.21 utf8 encoding problem and solution in Mac environment

1. Goal: Change the value of character_set_server...