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

Specific use of MySQL operators (and, or, in, not)

Table of contents 1. Introduction 2. Main text 2....

Detailed explanation of Javascript string methods

Table of contents String length: length charAt() ...

DockerToolBox file mounting implementation code

When using docker, you may find that the file can...

HTML Frameset Example Code

This article introduces a framework made by Frame...

Oracle deployment tutorial in Linux environment

1. Environment and related software Virtual Machi...

How to create a table by month in MySQL stored procedure

Without going into details, let's go straight...

Implementation of MySQL GRANT user authorization

Authorization is to grant certain permissions to ...

A brief talk about the diff algorithm in Vue

Table of contents Overview Virtual Dom principle ...

MySQL 8.0.12 installation and configuration method graphic tutorial (windows10)

This article records the installation graphic tut...

Tutorial on how to install htop on CentOS 8

If you are looking to monitor your system interac...

Several methods of implementing carousel images in JS

Carousel The main idea is: In the large container...