Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx configures virtual hosts based on multiple domain names, ports, and IP

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Type introduction

1.1 Domain name-based virtual host

The so-called domain name-based virtual host means to distinguish different virtual hosts through different domain names. Domain name-based virtual hosts are the most widely used virtual host types in enterprises, and almost all websites that provide services use domain name-based hosts, such as www.test1.com www.test2.com, etc.

1.2 Port-based virtual host

By the same token, the so-called port-based virtual host means to distinguish different virtual hosts through different ports. the corresponding enterprise applications of such virtual hosts are mainly internal websites of the company. for example, some websites that do not want to provide direct access to users, etc., access port-based virtual hosts with port numbers in their addresses Such as http://www.test.com:81 http://www.test.com:82, etc.

1.3 IP-based virtual host

By the same token, the so-called IP-based virtual host means to distinguish different virtual hosts through different IP. Enterprise applications corresponding to such virtual hosts are very rare. Generally, different business scenarios that need to use multi-IP will bind IP on load balancers. I am not binding IP on 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 nginx configuration file to configure multiple domain names, restart nginx service, create corresponding different site directories and upload site files, or use one site directory to access through multiple domain names

3. Virtual host configuration based on multi-port

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

4. Virtual host configuration based on multi-IP

Basic steps: add Nic to get multiple ip or add auxiliary ip, modify nginx configuration file to configure multi-ip, restart nginx service, create corresponding different site directories and upload site files, or use one site directory and access through multiple ip

4.2 ways to add secondary ip

4.2.1 temporary addition of secondary ip:

Method 1: ifconfig eth0:1 10.0.0.8 shock 24 up

Method 2: ip addr

Ip addr help View help

Ip addr add 10.0.0.9 dev eth0 24 dev eth0 (can be viewed using ip addr)

Ipaddr add 10.0.0.9 label eth0:2 dev eth0 24 label eth0:2 dev eth0 (can be viewed using both ifconfig and ipaddr, recommended)

4.2.2 permanent addition of secondary ip

Cd / etc/sysconfig/network-scripts/ # go to the directory of the network card configuration file cp ifcfg-eth0 ifcfg-eth0:1 # copy the configuration file and rename vim ifcfg-eth0:1 # edit the configuration file / etc/init.d/network restart # restart the network service

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report