当前位置:网站首页>10 minutes to thoroughly understand how to configure sub domain names to deploy multiple projects
10 minutes to thoroughly understand how to configure sub domain names to deploy multiple projects
2022-06-13 03:59:00 【Smoothzjc】
Hello everyone , I am a Smooth, A sophomore front-end enthusiast , The goal is to become a front-end development engineer
Configuring subdomains allows you to deploy multiple projects on one server at the same time
This article will explain in detail how to configure subdomains so that you can deploy multiple projects on one server at the same time , A tutorial that novices can understand, haha
demand
There are the following requirements :
I have a domain name zhangjiancong.top, I want to put some on it web application , Namely
- Personal blog :myblog.zhangjiancong.top
- Entertainment :xxx.zhangjiancong.top
One way is to nginx Of document myblog、xxx Catalog , The access method is zhangjiancong.top/myblog
zhangjiancong.top/xxx
But this has several disadvantages
- some web The application itself may not support non root directory access , Resulting in unavailability
- Because each application may need to location Special configuration of , These applications are not in the root path ,location Configuration may be different , More complicated
- Not cool enough , Too ugly
Need make myblog、xxx Each has its own subdomain (myblog.zhangjiancong.top、xxx.zhangjiancong.top), You can do that :
- At the domain name service provider , Add one more CNAME Record , Point the subdomain name to be configured to the host name corresponding to the root domain .
- Then modify it in the pagoda interface Nginx To configure
- Add new site
As follows
To configure
1. add to CNAME Record
This is alicloud , So Alibaba cloud is used as an example , No matter what service provider , Open the domain name resolution interface
Enter the domain name resolution interface
Click Add record
Configuration instructions
CNAME Record
When will it be used CNAME Record ?
[ If you need to point a domain name to another domain name , Provided by another domain name ip Address , You need to add CNAME Record ]
Most commonly used to CNAME This includes : do CDN, Configure subdomains
CNAME Notes on adding records
Remember to change the column "analysis line" to Default , China Unicom will only give an example to illustrate the role of this configuration item
Record type : choice
CNAME
Host record : Fill in subdomain name ( For example, you need to add myblog.zhangjiancong.top Parsing , Just fill in the host record myblog that will do ; If you add zhangjiancong.top Parsing Parsing , The host record is left blank , The system will automatically fill in a “@” To input box ).
Analytic circuit : The default can be ( If the default is not selected, some specific users will not be able to resolve ; The function in the above figure is : All users except Unicom users can normally parse )
Record value :CNAME Domain name pointed to , You can only fill in the domain name , After the record is generated, the domain name will be automatically followed by a “.”, It's normal
TTL: When adding, the system will automatically generate , The default is 600 second (TTL For cache time , The smaller the numerical , The faster the change takes effect ).
Click ok
2. modify Nginx The configuration file
Find this item in the pagoda interface
Find the configuration entry
For configuration files server Modify the fields as shown in the figure above
- Because my main domain name is another resource of mine loaf-community, So I
$doc
The initial value is"loaf-community"
, Otherwise""
that will do - if To match rules ,root Corresponding path resources for the server , My resources are all on
/www/wwwroot/
Under the directory of , You can configure it according to the real path of your server
# Set subdomain directory
set $doc "loaf-community";
if ($host ~ ^(\w+)\.zhangjiancong\.top) {
set $doc $1;
}
# Set the corresponding... Of the domain name at this time root
root /www/wwwroot/$doc;
The advantage of doing so is , Then add a subdomain name , As long as I'm in /www/wwwroot
Create a new subdirectory in the directory to put the new items , Take the subdomain name as the directory name , Then add a new word "domain name" in the domain name service provider CNAME The record is done , Very convenient .
3. Add new site
Find the entrance
Configure the subdomain name and its corresponding project resource path
After configuration, restart the server
After configuring the second step , After that, add new subdomains and items every time , Just go to step one and step three
The above is the whole content of this article
Last
Last , My name is Smooth, In this year 2022 In, I will also try my best to write more front-end tutorials , Looking forward to your attention ~
The latest document plan is Webpack
as well as performance optimization Knowledge system
边栏推荐
- [note]vs2015 compilation of masm32 using MASM32 Library
- Talking about the wavelength of laser radar
- Principle, composition and functions of sensors of Dajiang UAV flight control system
- MCU: RS485 communication and Modbus Protocol
- Big Five personality learning records
- Common array methods in JS (map, filter, foreach, reduce)
- Lambda termination operation find and match anymatch
- leetcode.1 --- 两数之和
- Lambda终结操作reduce归并
- 【Web】Cookie 和 Session
猜你喜欢
手机私有充电协议解读
Among the four common technologies for UAV obstacle avoidance, why does Dajiang prefer binocular vision
leetcode. 1 --- sum of two numbers
5G China unicom 直放站 网管协议 实时性要求
Single chip microcomputer: pcf8591 application program
[test development] automated test selenium (II) -- common APIs for webdriver
SCM: introduction to Modbus communication protocol
Fundamentals of robot obstacle avoidance system
[test development] fundamentals of software testing
Value of line height
随机推荐
Real time requirements for 5g China Unicom repeater network management protocol
单片机:EEPROM 多字节读写操作时序
EGO planner论文翻译
MCU: NEC protocol infrared remote controller
USB-IF BC1.2充电协议解读
Introduction to MCU peripherals: temperature sensor DS18B20
SCM signal generator program
十亿数据量 判断元素是否存在
UnionPay commerce - merchant statistics service platform
On the value of line height
[test development] blog system - LoadRunner performance test (publish blog function benchmark test)
Solution to failure to download files by wechat scanning QR code
Common array methods in JS (map, filter, foreach, reduce)
EGO Planner代码解析----CMakeLists.txt和package.xml
无人机避障四种常见技术中,为何大疆首选双目视觉
单片机:D/A 输出
LVS four layer load balancing cluster (3) cluster function classification - HPC
[test development] use case
Single chip microcomputer: pcf8591 application program
扫地机器人如何才能避障不“智障”?五种主流的避障技术解析