Use nginx + secondary domain name + https support

Use nginx + secondary domain name + https support

Step 1: Add a secondary domain name to the Alibaba Cloud primary domain name

The second step is to purchase the https protocol in Alibaba Cloud Security and bind the domain name. If it is only for testing, it is recommended to purchase the free version.

The third step is to configure the server of the secondary domain name in nginx

Nginx configures http to use port 80

Nginx configures https to use port 443

There are many ways to assign a secondary domain name to nginx. I use nginx to import folders here. All secondary domain name configurations are separated from the primary domain name configuration to avoid excessive coupling.

Import the directory folder where the secondary domain name is located into nginx

Directory where the second-level domain name is located

The secondary domain name configuration is as follows

The last step is to enter the nginx sbin directory and use the ./nginx -t command to check whether the configuration is wrong.

If the configuration is OK, restart with command ./nginx -s reload and the https application will be successful

The backend code must also be equipped with https service, please refer to the document for details

Additional knowledge: Problems encountered with nginx domain name redirection

At the request of the customer, a domain name needs to be assigned to the customer. Then our expert Qiang suggested that the backend should not be equipped with a domain name server, which is unsafe. Generally, domain names are only configured for external web servers.

Combined with another favorite blog post, install nginx and then modify the configuration file as follows:

---One domain name corresponds to one conf file;;;

server {
    listen 80; ——————————Fixed port 80
    server_name AB; ——————Commas separate the primary and secondary domain names location / {
      root /alidata1/tomcat-tes/……;————————Server absolute path root directory index index.html index.htm index.jsp;
      proxy_send_timeout 1200;
      proxy_connect_timeout 1200;
    proxy_pass http://121.41.*.216*;——————————The address to be compared 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;
    }
  location /share {————————Server business module secondary path index index.html index.htm index.jsp;
     proxy_send_timeout 1200;
         proxy_connect_timeout 1200;
         proxy_pass http://121.4*;
         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;
  }
  
  location /chao {
         index index.html index.htm index.jsp;
     proxy_send_timeout 1200;
         proxy_connect_timeout 1200;
         proxy_pass http://121.41.4*/;
         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;
  }
  }

After the modification, restart nginx command: service nginx restart

If necessary, restart Tomcat.

To configure a second domain name and another port login address in the same directory, you need to create another conf file

The above article about using nginx + secondary domain name + https support is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed analysis of each stage of nginx's http request processing
  • Nginx implements https website configuration code example
  • Detailed tutorial on configuring nginx for https encrypted access
  • Implementation of Nginx domain name forwarding https access
  • Alibaba Cloud Nginx configures https to implement domain name access project (graphic tutorial)
  • Nginx configures the same domain name to support both http and https access
  • Detailed configuration of Nginx supporting both Http and Https
  • Nginx handles http request implementation process analysis

<<:  Vue implementation example using Google Recaptcha verification

>>:  How to change the MySQL database directory location under Linux (CentOS) system

Recommend

Ajax jquery realizes the refresh effect of a div on the page

The original code is this: <div class='con...

What to do after installing Ubuntu 20.04 (beginner's guide)

Ubuntu 20.04 has been released, bringing many new...

Nine advanced methods for deduplicating JS arrays (proven and effective)

Preface The general methods are not listed here, ...

VMware Workstation 14 Pro installation and activation graphic tutorial

This article shares the installation and activati...

The difference between key and index in MySQL

Let's look at the code first: ALTER TABLE rep...

Install MySQL 5.7 on Ubuntu 18.04

This article is compiled with reference to the My...

Java uses Apache.POI to export HSSFWorkbook to Excel

Use HSSFWorkbook in Apache.POI to export to Excel...

How to deploy ElasticSearch in Docker

1. What is ElasticSearch? Elasticsearch is also d...

Implementation of Mysql User Rights Management

1. Introduction to MySQL permissions There are 4 ...

How to customize an EventEmitter in node.js

Table of contents Preface 1. What is 2. How to us...

How to create a view in MySQL

Basic syntax You can create a view using the CREA...

Troubleshooting and solutions for MySQL auto-increment ID oversize problem

introduction Xiao A was writing code, and DBA Xia...

Some parameter descriptions of text input boxes in web design

In general guestbooks, forums and other places, t...

Implementation of Single Div drawing techniques in CSS

You can often see articles about CSS drawing, suc...

How to call a piece of HTML code together on multiple HTML pages

Method 1: Use script method: Create a common head...