In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use location in Nginx". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use location in Nginx".
Grammar
Syntax: location [= | ~ | ~ * | ^ ~] uri {.} location @ name {...} Default:-Context: server. Location syntax states that location = / uri= starts with an exact match, which is valid only on the exact match. Location ^ ~ / uri ^ ~ begins with a prefix match on the URL path and comes before the regular. The beginning of location ~ pattern~ indicates a case-sensitive regular match. The beginning of location ~ * pattern~* indicates a case-insensitive regular match. Location / uri does not have any modifiers, which also means that the prefix matches, but after the regular match. Location / generic match, any request that does not match another location will be matched, which is equivalent to default in switch.
Exact matching has the highest priority.
If there is no exact match, then all irregular location in the configuration file will be matched to find the longest match. If the longest match starts with ^ ~, the match result is returned.
Match regular matches one by one. If the match is successful, return regular location. If not, return the longest matching result of step 2 matching.
Nginx can implement a partial replacement of the URL path when configuring proxy_pass.
The destination address of 1.proxy_pass, which does not take / by default, means that only the proxy domain name will be represented, and the url and querystring parts will not be changed (URL that splices the requested path to the proxy_pass target domain name as the proxy)
two。 If / is added after the destination address, the successful part of the location match in the path is cut off and then spliced to the proxy_pass destination address.
Example:
Server {location / abc {proxy_pass http://server_url;} location / abc {proxy_pass http://server_url/;}}
Such as request / abc/b.html
After the above two matches are successful, the target url of the actual agent is respectively
Http://server_url/abc/b.html (after splicing / abc/b.html to http://server_url)
Http://server_url/b.html (after removing / abc from / abc/b.html, splicing it to http://server_url/)
Thank you for your reading, the above is the content of "how to use Nginx location", after the study of this article, I believe you have a deeper understanding of how to use Nginx location, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.