Logical operations
the logic and && logic of the IF condition is not supported in the Nginx configuration or | | Operation, and the nested syntax for if is not supported, the following error is reported: Nginx: [Emerg] Invalid condition.
We can do this indirectly by means of variables.
The statement to implement:
if ($arg _unitid = 42012 && $uri ~/thumb/) {
echo "www.jb51.net";
}
If you configure this, you will report nginx: [Emerg] Invalid condition error.
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";
}
Nginx to convert uppercase and lowercase letters (ngx_http_lower_upper_case modules)
a variety of programs or scripts have the ability to achieve the conversion of uppercase and lowercase letters, today, Ngx_http_lower_upper_case, the function is very simple, As for what can be used in the environment you can according to their own situation. One more module, one more solution. This module converts a string to a case and then assigns it to a variable. In the phrase "existence is reasonable", the existence of software always has its own truth.
1. Install Nginx module
--add-module=path/to/circle_gif/directory
The specific method is no longer described, you can refer to the operation of survival time < How to install Nginx third Party module >
2.upper/lower directives
Upper
Syntax: Upper $var string
Configuration segment: Location
Small capitalization
Lower
Syntax: Lower $var string
Configuration segment: Location
Uppercase to lowercase
3. Nginx Configuration
Location/ttlsa_upper_lower {
upper $var 1 "hello,jb51.net";
Lower $var 2 "hello,jb51.net";
echo $var 1;
echo $var 2;
}
4. Test
# Curl http://test.jb51.net/ttlsa_upper_lower/
Hello,jb51.net
hello,jb51.net
Nginx Module Address: https://github.com/replay/ngx_http_lower_upper_case/archive/master.zip
Ngx_http_lower_upper_case Address: Https://github.com/replay/ngx_http_lower_upper_case