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

Introduction to RHCE bridging, password-free login and port number modification

Table of contents 1. Configure bridging and captu...

Let's talk about the LIMIT statement in MySQL in detail

Table of contents question Server layer and stora...

Mac VMware Fusion CentOS7 configuration static IP tutorial diagram

Table of contents Install CentOS7 Configuring Sta...

Tutorial on deploying the open source project Tcloud with Docker on CentOS8

1. Install Docker 1. I installed Centos7 in the v...

Implementation of tomcat image created with dockerfile based on alpine

1. Download the alpine image [root@docker43 ~]# d...

How to implement input checkbox to expand the click range

XML/HTML CodeCopy content to clipboard < div s...

A brief analysis of the usage of HTML float

Some usage of float Left suspension: float:left; ...

HTML displays ellipsis beyond the text... implemented through text-overflow

You need to apply CSS to div or span at the same t...

The process of building lamp architecture through docker container

Table of contents 1. Pull the centos image 2. Bui...

js implements a simple English-Chinese dictionary

This article shares the specific code of js to im...

About vue component switching, dynamic components, component caching

Table of contents 1. Component switching method M...

A brief discussion of 3 new features worth noting in TypeScript 3.7

Table of contents Preface Optional Chaining Nulli...

Html makes a simple and beautiful login page

Let’s take a look first. HTML source code: XML/HT...

4 ways to implement routing transition effects in Vue

Vue router transitions are a quick and easy way t...