Nginx configuration based on multiple domain names, ports, IP virtual hosts

Nginx configuration based on multiple domain names, ports, IP virtual hosts

1. Type introduction

1.1 Domain-based virtual hosting

The so-called domain name-based virtual host means that different virtual hosts are distinguished by different domain names. Domain name-based virtual hosts are the most widely used virtual host type in enterprises. Almost all websites that provide services to the outside world use domain name-based hosts, such as www.test1.com www.test2.com, etc.

1.2 Port-based virtual hosts

Similarly, the so-called port-based virtual host means that different virtual hosts are distinguished by different ports. The enterprise applications corresponding to this type of virtual host are mainly internal company websites, such as: some website backends that do not want to provide direct user access to the outside world, etc. To access a port-based virtual host, the address must contain the port number, such as http://www.test.com:81 http://www.test.com:82, etc.

1.3 IP-based virtual hosts

Similarly, the so-called IP-based virtual host means distinguishing different virtual hosts by different IPs. Enterprise applications corresponding to such virtual hosts are very rare. Generally, scenarios where different businesses need to use multiple IPs will bind IPs on the load balancing. I do not bind IPs on the web to distinguish different virtual machines.

All three types of virtual hosts can be used independently or mixed.

2. Virtual host configuration based on multiple domain names

Basic steps: modify the nginx configuration file to configure multiple domain names, restart the nginx service, create corresponding different site directories and upload site files, or use one site directory and access it through multiple domain names

3. Virtual host configuration based on multiple ports

Basic steps: modify the nginx configuration file to configure multiple ports, restart the nginx service, modify the security group rules to open ports, create corresponding different site directories and upload site files, or use one site directory and access it through multiple ports

4. Virtual host configuration based on multiple IPs

4.1 Basic steps: add a network card to obtain multiple IPs or add auxiliary IPs, modify the nginx configuration file to configure multiple IPs, restart the nginx service, create corresponding different site directories and upload site files, or use one site directory and access it through multiple IPs

4.2 How to add auxiliary IP

4.2.1 Temporarily add auxiliary IP:

Method 1: ifconfig eth0:1 10.0.0.8/24 up

Method 2: ip addr

ip addr help View help

ip addr add 10.0.0.9/24 dev eth0 (use ip addr to view)

ip addr add 10.0.0.9/24 label eth0:2 dev eth0 (both ifconfig and ipaddr can be used to view, recommended)

4.2.2 Permanently add auxiliary IP

cd /etc/sysconfig/network-scripts/ #Enter the directory of the network card configuration file cp ifcfg-eth0 ifcfg-eth0:1 #Copy the configuration file and rename it vim ifcfg-eth0:1 #Edit the configuration file /etc/init.d/network restart #Restart the network service 

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:
  • How to install Nginx and configure multiple domain names
  • How to configure multiple domain names on one nginx server
  • Nginx multi-domain configuration method
  • Detailed explanation of implementing Nginx+Tomcat to achieve single IP, multiple domain names, and multiple sites access
  • Nginx multi-domain simple configuration tutorial under Windows
  • Detailed nginx multi-domain configuration method
  • Detailed explanation of three ways to configure Nginx virtual hosts (based on ports)

<<:  Basic usage knowledge points of mini programs (very comprehensive, recommended!)

>>:  MySQL 8.0.12 installation and environment variable configuration tutorial under win10

Recommend

Five delay methods for MySQL time blind injection

Five delay methods for MySQL time blind injection...

MySQL merges multiple rows of data based on the group_concat() function

A very useful function group_concat(), the manual...

Vue3 list interface data display details

Table of contents 1. List interface display examp...

Detailed explanation of the use of MySQL paradigm

1. Paradigm The English name of the paradigm is N...

How to use echarts to visualize components in Vue

echarts component official website address: https...

Some thoughts and experience sharing on web page (website) design and production

First, before posting! Thanks again to I Want to S...

How to manually upgrade the node version under CentOs

1. Find the corresponding nodejs package, refer t...

CSS3 animation to achieve the effect of streamer button

In the process of learning CSS3, I found that man...

Complete steps to implement face recognition login in Ubuntu

1. Install Howdy: howdy project address sudo add-...

Detailed explanation of several error handling when Nginx fails to start

When using Nginx as a Web server, I encountered t...

HTML tags list and usage instructions

List of HTML tags mark type Name or meaning effec...

Web page html special symbols html special characters comparison table

Special symbols Named Entities Decimal encoding S...

Solution to mysql prompt "got timeout reading communication packets"

Error message: user: 'root' host: `localh...