mongo-array-filter:
https://tpiros.dev/blog/retrieve-only-queried-element-in-an-object-array-in-mongodb-collection/
Redis & Redis-stack:
url: ‘redis://db-redis.xxx’
apt-get install redis
>/etc/redis/redis/conf
>>bind 0.0.0.0
>>requirepass xxxx
docker:
docker run --name redis -d \
-p 6379:6379 \
--restart always \
-v /data:/data \
-e REDIS_PASSWORD=xxx \
redis sh -c 'redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}'
gui:
https://redis.io/docs/manual/admin/
https://github.com/qishibo/AnotherRedisDesktopManager
stream {
server {
listen 6380 so_keepalive=on;
proxy_connect_timeout 2s;
proxy_timeout 10m;
# docker-redis
proxy_pass 127.0.0.1:6379;
}
server {
listen 27017 ssl so_keepalive=on;
ssl_certificate xxx
ssl_certificate_key xxx;
proxy_connect_timeout 2s;
proxy_timeout 10m;
# docker-mongo-1
proxy_pass 127.0.0.1:27017;
}
server {
listen 3306 ssl so_keepalive=on;
ssl_certificate xxx;
ssl_certificate_key xxx;
proxy_connect_timeout 1s;
proxy_timeout 3s;
# docker-mysql-1
proxy_pass 127.0.0.1:3306;
}
}
http {
server
{
listen 127.0.0.1:XXX proxy_protocol;
server_name mongo-gui.xxx;
index index.html index.htm index.php default.php default.htm default.html;
add_header Strict-Transport-Security "max-age=63072000" always;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:xxx;
}
}
server
{
listen 127.0.0.1:XXX proxy_protocol;
server_name mysql-gui.xxx;
index index.html index.htm index.php default.php default.htm default.html;
add_header Strict-Transport-Security "max-age=63072000" always;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:xxx;
}
}
}
Nginx variable
$args : 这个变量等于请求行中的参数,同$query_string
$content_length : 请求头中的Content-length字段
$content_type : 请求头中的Content-Type字段
$document_root : 当前请求在root指令中指定的值
$host : 请求主机头字段,否则为服务器名称
$http_user_agent : 客户端agent信息
$http_cookie : 客户端cookie信息
$limit_rate : 这个变量可以限制连接速率
$request_method : 客户端请求的动作,通常为GET或POST
$remote_addr : 客户端的IP地址
$remote_port : 客户端的端口
$remote_user : 已经经过Auth Basic Module验证的用户名
$request_filename : 当前请求的文件路径,由root或alias指令与URI请求生成
$scheme : HTTP方法(如http,https)
$server_protocol : 请求使用的协议,通常是HTTP/1.0或HTTP/1.1
$server_addr : 服务器地址,在完成一次系统调用后可以确定这个值
$server_name : 服务器名称
$server_port : 请求到达服务器的端口号
$request_uri : 包含请求参数的原始URI,不包含主机名,如/foo/bar.php?arg=baz
$uri : 不带请求参数的当前URI,$uri不包含主机名,如/foo/bar.html
$document_uri : 与$uri相同
假设请求为http://www.qq.com:8080/a/b/c.php,则
$host:www.qq.com
$server_port:8080
$request_uri:http://www.qq.com:8080/a/b/c.php
$document_uri:/a/b/c.php
$document_root:/var/www/html
$request_filename:/var/www/html/a/b/c.php
主机名(server_name)匹配
从上到下的优先级为从高到低
明确的server_name名称,如www.qq.com
前缀通配符,如*.qq.com或. qq.com
后缀通配符,如www.qq.*
正则表达式,如~[a-z]+\.qq\.com
Location查找规则
从上到下的优先级为从高到低
等号类型,精确匹配,如location = / {}
^~类型,前缀匹配,不支持正则,如location ^~ /user {}
~和~*类型,正则匹配,~区分大小写,~*不区分大小写,如location ~ ^/user {}
常规字符串匹配类型,如location / {}或location /user {}
Try_files规则
try_files $uri $uri/ /index.php
假设请求为http://www.qq.com/test,则$uri为test
查找/$root/test文件
查找/$root/test/目录
发起/index.php的内部“子请求”
Rewrite规则
rewrite ^/images/(.*).(png|jpg|gif)$ /images?name=$1.$4 last;
上面的rewrite规则会将文件名改写到参数中
last : 相当于Apache的[L]标记,表示完成rewrite
break : 停止执行当前虚拟主机的后续rewrite指令集
redirect : 返回302临时重定向,地址栏会显示跳转后的地址
permanent : 返回301永久重定向,地址栏会显示跳转后的地址