How to bind domain name to nginx service

How to bind domain name to nginx service

Configure multiple servers in nginx.conf:

When processing an http request, nginx will take out the host in the header and match it with the server_name of each server in nginx.conf to determine which server block will handle the request.

The server_name inside: is used to configure name-based virtual hosts

In addition to exact matches, you can also use wildcards:

1. A string starting with the * wildcard character:

server_name *.domain.com;

2. Characters ending with the * wildcard

server_name www.*;

3. Matching regular expressions

server_name ~^(?.+).domain.com$;
server {
   listen 80 default_server;
   server_name www.123.com;
   root /home/web1;
   location / {
   }
   error_page 404 /404.html;
     location = /40x.html {
   }
   error_page 500 502 503 504 /50.xhtml;
     location = /50x.html {
   }
 }
server {
   server_name www.abc.com;
   root /home/web2;
   location / {
   }
   error_page 404 /404.html;
     location = /40x.html {
   }
   error_page 500 502 503 504 /50x.html;
     location = /50x.html {
   }
 }

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:
  • Detailed explanation of how to bind domain name and set root directory to nginx server
  • Nginx reverse proxy secondary domain name binding method and precautions
  • How to configure nginx to bind the matching domain name of the wildcard resolution to the subdirectory

<<:  JS implements simple calendar effect

>>:  MySQL implements increasing or decreasing the specified time interval for all times in the current data table (recommended)

Recommend

Tutorial on installing mysql5.7.36 database in Linux environment

Download address: https://dev.mysql.com/downloads...

Completely delete MySQL steps

Table of contents 1. Stop MySQL Server first 2. U...

MySQL 8.0.20 installation and configuration tutorial under Win10

MySQL 8.0.20 installation and configuration super...

Detailed explanation of Deepin using docker to install mysql database

Query the MySQL source first docker search mysql ...

TypeScript problem with iterating over object properties

Table of contents 1. Problem 2. Solution 1. Decla...

Reasons for the sudden drop in MySQL performance

Sometimes you may encounter a situation where a S...

CentOS7 installation GUI interface and remote connection implementation

Use the browser (webdriver)-based selenium techno...

How to set the border of a web page table

<br />Previously, we learned how to set cell...

Summary of practical methods for JS beginners to process arrays

join() method: connects all elements in an array ...

Solution to the problem that the mysql8.0.11 client cannot log in

This article shares with you the solution to the ...

Summary of 7 reasons why Docker is not suitable for deploying databases

Docker has been very popular in the past two year...

MySQL-8.0.26 Configuration Graphics Tutorial

Preface: Recently, the company project changed th...

Linux file systems explained: ext4 and beyond

Today I will take you through the history of ext4...

How to use HTML form with multiple examples

Nine simple examples analyze the use of HTML form...