How to create https using nginx and Tencent Cloud free certificate

How to create https using nginx and Tencent Cloud free certificate

I have been studying how to get https. Recently I saw the free SSL certificate provided by Tencent Cloud, and I was thinking about making the website https.

First, go to Tencent Cloud to purchase a free certificate.

Click to fill in the content.

Then download the certificate

Unzip the certificate and you can see that there are four ways to modify https. The one we need is

Contents of the Nginx package.

The certificate is finished here.

Then let me talk about the project configuration. My website project is made with springboot, and the port number is 8888.

Then install nginx on the server. I won’t go into details about the installation. If you don’t understand, just search on Baidu. It’s very simple. All that needs to be said is the nginx.conf configuration:

 ##Here is to redirect the default http port 80 to https
  server {
    listen 80;
    server_name www.dalaoyang.cn;
    rewrite ^ https://$http_host$request_uri? permanent; 
  }
  
  ##Here is to intercept the default request to https port 443## and forward the request to http://127.0.0.1:8888/
  server {
    listen 443;
    server_name www.dalaoyang.cn;
    ssl on;   
     ssl_certificate 1_dalaoyang.cn_bundle.crt;
    ssl_certificate_key 2_dalaoyang.cn.key;
    ssl_session_timeout 5m;
    location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;
        #Your project port number proxy_pass http://127.0.0.1:8888/;
      proxy_redirect off;
    }
  }

Then enter www.dalaoyang.cn on the website and you can see the following picture

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to deploy HTTPS for free on Tencent Cloud
  • Tencent Cloud applies for a free SSL certificate and configures Tomcat to change http to https

<<:  How to get the width and height of the image in WeChat applet

>>:  mysql5.5 installation graphic tutorial under win7

Recommend

Summary of Binlog usage of MySQL database (must read)

I won't go into details about how important b...

8 tips for Vue that you will learn after reading it

1. Always use :key in v-for Using the key attribu...

Elegant practical record of introducing iconfont icon library into vue

Table of contents Preface Generate SVG Introducti...

Solve the problem of docker pull image error

describe: Install VM under Windows 10, run Docker...

JavaScript pie chart example

Drawing EffectsImplementation Code JavaScript var...

How to implement vue page jump

1. this.$router.push() 1. Vue <template> &l...

JavaScript implements the generation of 4-digit random verification code

This article example shares the specific code for...

PHP scheduled backup MySQL and mysqldump syntax parameters detailed

First, let's introduce several common operati...

Docker deploys nginx and mounts folders and file operations

During this period of time, I was studying docker...

Network management and network isolation implementation of Docker containers

1. Docker network management 1. Docker container ...

How to install and configure WSL on Windows

What is WSL Quoting a passage from Baidu Encyclop...

A brief discussion on React Component life cycle functions

What are the lifecycle functions of React compone...

Detailed explanation of JavaScript state container Redux

Table of contents 1. Why Redux 2. Redux Data flow...