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

A simple example of MySQL joint table query

MySql uses joined table queries, which may be dif...

Docker dynamically exposes ports to containers

View the IP address of the Container docker inspe...

MySQL pessimistic locking and optimistic locking implementation

Table of contents Preface Actual Combat 1. No loc...

Detailed explanation of angular two-way binding

Table of contents Bidirectional binding principle...

Vue+echart realizes double column chart

This article shares the specific code of vue+echa...

Solve the problem of the container showing Exited (0) after docker run

I made a Dockerfile for openresty on centos7 and ...

Videojs+swiper realizes Taobao product details carousel

This article shares the specific code of videojs+...

Windows cannot start MySQL service and reports error 1067 solution

Suddenly when I logged into MySQL, it said that a...

CentOS 7 cannot access the Internet after modifying the network card

Ping www.baidu.com unknown domain name Modify the...

Java imports data from excel into mysql

Sometimes in our actual work, we need to import d...

Solution to docker suddenly not being accessible from the external network

According to the methods of the masters, the caus...

A brief introduction to the command line tool mycli for operating MySQL database

GitHub has all kinds of magic tools. Today I foun...

Detailed tutorial on installing Docker and docker-compose suite on Windows

Table of contents Introduction Download and insta...

How to run the react project on WeChat official account

Table of contents 1. Use the a tag to preview or ...