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

Detailed explanation of asynchronous iterators in nodejs

Table of contents Preface What are asynchronous i...

40 web page designs with super large fonts

Today's web designs tend to display very larg...

6 Uncommon HTML Tags

First: <abbr> or <acronym> These two s...

MySQL 8.0.19 installation and configuration tutorial under Windows 10

I will be learning MySQL next semester. I didn...

Detailed explanation of asynchronous programming knowledge points in nodejs

Introduction Because JavaScript is single-threade...

Example analysis of the impact of MySQL index on sorting

This article uses examples to illustrate the impa...

Six border transition effects implemented by CSS3

Six effectsImplementation Code html <h1>CSS...

JS realizes the effect of Baidu News navigation bar

This article shares the specific code of JS to ac...

A useful mobile scrolling plugin BetterScroll

Table of contents Make scrolling smoother BetterS...

Detailed Analysis of Explain Execution Plan in MySQL

Preface How to write efficient SQL statements is ...

How to create a Pod in Kubernetes

Table of contents How to create a Pod? kubectl to...

Implementation of Nginx hot deployment

Table of contents Semaphore Nginx hot deployment ...

An example of how JavaScript can prevent duplicate network requests

Preface During development, we often encounter va...

Summary of uncommon js operation operators

Table of contents 2. Comma operator 3. JavaScript...

Detailed introduction to CSS font, text, and list properties

1. Font properties color, specifies the color of ...