Complete steps to upgrade Nginx http to https

Complete steps to upgrade Nginx http to https

The difference between http and https is

For some websites, when http is opened, the page prompts that it is not safe. For example, if you click on the website below [it is actually the same website]

http://www.511easy.com/bug/login

http://www.88bugs.com/bug/login

How can I remove this unsafe prompt? Upgrade from http to https

Take a look at the final effect:

If you currently have a website, how do you upgrade it to https?

Domain name: 511easy.com

If you have a domain name, you can apply for a free SSL certificate. As shown in the following screenshot, based on the certificates of various web servers, I use Nginx here.

Then you need to configure nginx.conf, probably use the third one below, the first two are what I use to save.

Compared with http, https is more secure, but not necessarily. Use jmeter/charles/wireshark/fiddle to generate a certificate, and you can easily capture packets on https websites. I can capture packets on most websites and apps.

 upstream tomcatserver1 {
  server 127.0.0.1:8083;
  }
 upstream tomcatserver2 {
  server 127.0.0.1:8085;
  }
   
   
   
server {
  listen 80;
  server_name 511easy.com;
 
 
  location / {
   proxy_pass http://tomcatserver1;
   index index.html index.htm;
  } 
 }
server {
  listen 80;
  server_name 511easy.com;
 
  location / {
   proxy_pass http://tomcatserver2;
   index index.html index.htm;
  }  
 }
worker_processes 1;
 
events {
 worker_connections 1024;
}
 
 
http {
 include mime.types;
 default_type application/octet-stream;
 
 sendfile on;
 
 keepalive_timeout 65;
 
 server {
  listen 80;
  server_name 88bugs;
  location / {
   proxy_pass http://localhost:8083;
  }
  }
 
 server {
  listen 80;
  server_name jenkins;
  location / {
   proxy_pass http://localhost:8080;
  }
  }
}
worker_processes 1;
 
events {
 worker_connections 1024;
}
 
 
http {
 include mime.types;
 default_type application/octet-stream;
 
 sendfile on;
 
 keepalive_timeout 65;
 
 
  server {
  listen 443 ssl;
  server_name www.511easy.com;
  
  ssl on;
  ssl_certificate 1_511easy.com_bundle.crt;
  ssl_certificate_key 2_511easy.com.key;
  ssl_session_timeout 5m;
   
  location / {
   proxy_pass http://localhost:8083;
  }
 
  }
}

Let’s consolidate the meanings of these abbreviations.

HTTP --- Hyper Text Transfer Protocol, Hypertext Transfer Protocol, is a stateless connection built on TCP. The basic workflow is that the client sends an HTTP request

HTTPS ---- Hyper Text Transfer Protocol over Secure Socket Layer or Hypertext Transfer Protocol Secure

The full name is: Hypertext Transfer Protocol Secure, which can be simply understood as the HTTP protocol using SSL encrypted transmission

The default port for HTTP is 80 and the default port for HTTPS is 443
SSL is a security protocol that provides security and data integrity for network communications.

Why Use HTTPS

To protect the security of information transmission and data integrity. It makes visitors feel that the website is trustworthy. For the domestic network environment, it can also prevent broadband operators from forcing advertisements on the website.

If you want to use two ports on a server and use different domain names to execute different ports, Nginx can be configured like this

worker_processes 1;
 
events {
 worker_connections 1024;
}
 
 
http {
 include mime.types;
 default_type application/octet-stream;
 
 sendfile on;
 
 keepalive_timeout 65;
 
 
  server {
  listen 443 ssl;
  server_name www.88bugs.com;
  
  ssl_certificate 1_88bugs.com_bundle.crt;
  ssl_certificate_key 2_88bugs.com.key;
  ssl_session_timeout 5m;
   
  location / {
   proxy_pass http://localhost:8083;
  }
  }
  
  server {
  listen 443 ssl;
  server_name www.511easy.com;
  
  ssl_certificate 1_511easy.com_bundle.crt;
  ssl_certificate_key 2_511easy.com.key;
  ssl_session_timeout 5m;
   
  location / {
   proxy_pass http://localhost:8085;
  }
  } 
}

https://www.88bugs.com/bug/login

https://www.511easy.com/ [Currently modified to point to another port project]

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • Example code for using Nginx to implement 301 redirect to https root domain name
  • Nginx domain name SSL certificate configuration (website http upgraded to https)
  • Springboot single architecture http request conversion https request to support WeChat applet calling interface
  • How does the Spring Boot project support both HTTP and HTTPS protocols?
  • How to configure SSL certificate in nginx to implement https service
  • Detailed explanation of the pitfalls of passing HttpServletRequest parameters to asynchronous threads under the Spring framework
  • Nexus uses nginx proxy to support HTTPS protocol

<<:  Let's talk about what JavaScript's URL object is

>>:  How to start multiple MySQL instances in CentOS 7.0 (mysql-5.7.21)

Recommend

Three ways to implement waterfall flow layout

Preface When I was browsing Xianyu today, I notic...

An example of using Dapr to simplify microservices from scratch

Table of contents Preface 1. Install Docker 2. In...

SQL implementation of LeetCode (181. Employees earn more than managers)

[LeetCode] 181.Employees Earning More Than Their ...

Application example tutorial of key in Vue page rendering

introduction During the front-end project develop...

Introduction to local components in Vue

In Vue, we can define (register) local components...

An example of elegantly writing status labels in Vue background

Table of contents Preface optimization Extract va...

Detailed explanation of using JavaScript WeakMap

A WeakMap object is a collection of key/value pai...

Problem record of using vue+echarts chart

Preface echarts is my most commonly used charting...

Similar to HTML tags: strong and em, q, cite, blockquote

There are some tags in XHTML that have similar fu...

How to design and create adaptive web pages

With the popularization of 3G, more and more peop...

How to perform query caching in MySQL and how to solve failures

We all know that we need to understand the proper...

CentOS7.5 installation of MySQL8.0.19 tutorial detailed instructions

1. Introduction This article does not have screen...