The environment that

Server system: Ubuntu 18.04 64-bit

Nginx: 1.14

This article mainly describes the steps of configuring HTTPS, but does not cover the details of applying for ca certificates

There is a free SSL certificate here: cloud.tencent.com/act/pro/ssl

I am the domain name of western digital, certificate applied for in Tencent cloud

After you apply for and issue a certificate, download the certificate to your local PC

1. Install nginx

$apt-get install nginx $apt-get install nginxCopy the code

2. Configure the CA certificate

2.1 The nginx installation directory is /etc/nginx/. Go to the /etc/nginx installation directory, add the cert folder, and upload the downloaded files to the cert folder

2.2 Add a blog.conf configuration file to /etc/nginx/conf.d/. Nginx will read all configuration files in conf.d/

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

server {
    listen 443;
    server_namexiaoxina.cc; // Your domain namessl on;
    root/var/lib/jenkins/workspace/blog; // Your website source directoryindex index.html index.htm;
    ssl_certificate/etc/nginx/cert/xiaoxina.cc.crt; // Certificate addressssl_certificate_key/etc/nginx/cert/xiaoxina.cc.key; // Certificate addressssl_session_timeout 10m;
    ssl_ciphersECDHE-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 / {
        indexindex.html index.htm; }}server {
    listen 80;
    server_namexiaoxina.cc; // Your domain namerewrite^ (. *) $ https://$hostThe $1 permanent;
}
Copy the code

After the configuration is complete, check whether the nginx configuration file is available

$ nginx -t
Copy the code

After the configuration is correct, reload the configuration file for the configuration to take effect.

$ service nginx reload
Copy the code

Read the text: Essays by Xiaoxin