In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains the "Nginx how to achieve configuration writing support logic operations and uppercase and lowercase conversion", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Nginx how to achieve configuration writing to support logical operations and uppercase and lowercase conversion" bar!
Logical operation
The logic of if condition and & & logic or | | operation are not supported in the configuration of nginx, and the nested syntax of if is not supported, otherwise the following error will be reported: nginx: [emerg] invalid condition.
We can implement it indirectly in the form of variables.
The statement to be implemented:
If ($arg_unitid = 42012 & & $uri ~ / thumb/) {echo "www.jb51.net";}
If configured in this way, a nginx: [emerg] invalid condition error will be reported.
This can be done as follows:
Set $flag 0 if ($uri ~ ^ / thumb/ [0-9] + _ 160.jpg$) {set $flag "${flag} 1";} if ($arg_unitid = 42012) {set $flag "${flag} 1";} if ($flag = "011") {echo "www.jb51.net";}
Conversion of uppercase and lowercase letters by nginx (ngx_http_lower_upper_case module)
All kinds of programs or scripts have the function of converting uppercase and lowercase letters. Today we will talk about ngx_http_lower_upper_case. The function is very simple. As for what environment you can use, you can use it according to your own situation. One more module and one more solution. This module converts strings to case and then assigns values to variables. As the saying goes, "existence is reasonable". There is always a reason for the existence of software.
1. Install the nginx module
-- add-module=path/to/circle_gif/directory
The specific method is no longer described, you can refer to the survival time of the operation and maintenance staff.
2.upper/lower instruction
Upper
Syntax: upper $var string
Configuration segment: location
Turn smaller to uppercase.
Lower
Syntax: lower $var string
Configuration segment: location
Turn uppercase to lowercase
3. Nginx configuration
Location / ttlsa_upper_lower {upper $var1 "hello,jb51.net"; lower $var2 "hello,jb51.net"; echo $var1;echo $var2;}
4. test
# curl http://test.jb51.net/ttlsa_upper_lower/ hello,jb51.net hello,jb51.net Thank you for your reading. The above is the content of "how to support logical operation and uppercase conversion when writing configuration in Nginx". After the study of this article, I believe you have a deeper understanding of how Nginx can support logical operation and uppercase and lowercase conversion when writing configuration. The specific use situation still needs to be verified by 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.