In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Today Xiaobian brings you an article introducing the configuration and location of nginx virtual machines. Xiao Bian thinks it is quite practical, so share it for everyone to make a reference. Let's follow the editor and have a look.
A virtual host server { listen 80; server_name www.yang.com; #Virtual machine host key, the same ip port, virtual machine host is to rely on the domain name here to route content root /yang/; #root directory index index.html index.php; access_log /yang/yang_com_access.log main; location / { }}
#Virtual machine hosts only need to start another.conf file in the conf.d directory, where the server segment is configured. If it is the same ip port, use the domain name to distinguish it, just like the code above.
II.Location
priority
= Exact match: used before standard uri, requires exact match between request string and uri. If the match is successful, stop matching and immediately execute the request in the location.~ Regular matching: used before regular uri, indicating that uri contains regular and case-sensitive.~* Regular matching: used before regular uri, indicating that uri contains regular, case-insensitive.^~ Irregular matching; before standard uri, nginx server matches uri with the most prefixes and ends. After the pattern matches successfully, regular matching will not be used. no Normal match (\); independent of location order, match results are obtained according to the length of match. If there is a perfect match, stop matching. PS: Priority from high to low
1 "=" Exact match
location = /news/ { echo "test1"; }[root@www quail]# curl 192.168.249.132/news/test1
2 "~" case-sensitive regular matching
location ~ \. (html) { echo 'test2';}location ~ \. (htmL) { echo 'test3';}[root@www quail]# curl 192.168.249.132/index.htmltest2[root@www quail]# curl 192.168.249.132/index.htmLtest3
3 "~*" Case-insensitive regular matching
location ~* \. (html){ echo 'test4';}[root@www quail]# curl 192.168.249.132/index.htmLtest4[root@www quail]# curl 192.168.249.132/index.htmltest4
4 "^~" Standard matching without regular matching, matching only prefixes
location ^~ /index/ { echo 'test5';}[root@www quail]# curl 192.168.249.132/index/test5[root@www quail]# curl 192.168.249.132/index/heiheitest5[root@www quail]# curl 192.168.249.132/index/asdnmkalsjdtest5
5 Common matches
location / { echo 'test6';}[root@www quail]# curl 192.168.249.132test6
The above is the details of the nginx virtual machine configuration and location use method. Is there any harvest after reading it? If you want to know more about it, welcome to pay attention to industry information!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.