Nginx 核心配置-location的匹配案例实战篇
Nginx核心配置-location的匹配案例实战篇
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.location语法规则介绍
在没有使用正则表达式的时候,nginx会先在server中的多个location选取匹配度最高的一个uri,uri是用户请求的字符串,即域名后面的web文件路径,然后使用location模块中的正则url和字符串,如果匹配成功就结束搜索,并使用此location处理此请求。
语法规则: location [=|~|~*|^~] /uri/ { … }
=:
用于标准uri前,需要请求字串与uri精确匹配,如果匹配成功就停止向下匹配并立即处理请求。
~:
用于标准uri前,表示包含正则表达式并且区分大小写
~*:
用于标准uri前,表示包含正则表达式并且不区分大写
!~:
用于标准uri前,表示包含正则表达式并且区分大小写不匹配
!~*:
用于标准uri前,表示包含正则表达式并且不区分大小写不匹配
^~:
用于标准uri前,表示包含正则表达式并且匹配以什么开头
$:
用于标准uri前,表示包含正则表达式并且匹配以什么结尾
\:
用于标准uri前,表示包含正则表达式并且转义字符。可以转. * ?等
*:
用于标准uri前,表示包含正则表达式并且代表任意长度的任意字符
二.匹配案例-精确匹配
1>.编辑主配置文件(本篇博客试验过程并不修改主配置文件内容哟)
[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/nginx/conf/nginx.conf
worker_processes 4;
worker_cpu_affinity 00000001 00000010 00000100 00001000; events {
worker_connections 100000;
use epoll;
accept_mutex on;
multi_accept on;
} http {
include mime.types;
default_type application/octet-stream;
sendfile on;
gzip on;
charset utf-8;
keepalive_timeout 65 65; #导入其他路径的配置文件
include /yinzhengjie/softwares/nginx/conf.d/*.conf;
} [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nginx -t
nginx: the configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf test is successful
[root@node101.yinzhengjie.org.cn ~]#
2>.编辑子配置文件
[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/nginx/conf.d/location.conf
server {
listen 80;
server_name node101.yinzhengjie.org.cn; location / {
root /yinzhengjie/data/web/nginx/html/image;
index index.html;
} location /01.jpg {
root /yinzhengjie/data/web/nginx/html;
index index.html;
}
}
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nginx -t
nginx: the configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf test is successful
[root@node101.yinzhengjie.org.cn ~]#
3>.创建测试数据
[root@node101.yinzhengjie.org.cn ~]# ll
total 364
-rw-r--r-- 1 root root 248743 Dec 15 22:38 01人柱力.jpg
-rw-r--r-- 1 root root 122026 Dec 16 2019 02.迪丽热巴.jfif
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cp 01人柱力.jpg /yinzhengjie/data/web/nginx/html/image/01.jpg
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cp 02.迪丽热巴.jfif /yinzhengjie/data/web/nginx/html/01.jpg
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll -R /yinzhengjie/data/web/nginx/html/
/yinzhengjie/data/web/nginx/html/:
total 124
-rw-r--r-- 1 root root 122026 Dec 16 19:35 01.jpg
drwxr-xr-x 2 root root 38 Dec 16 19:35 image
-rw-r--r-- 1 root root 88 Dec 15 23:13 index.html /yinzhengjie/data/web/nginx/html/image:
total 248
-rw-r--r-- 1 root root 248743 Dec 16 19:35 01.jpg
-rw-r--r-- 1 root root 49 Dec 15 23:07 index.html
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
4>.启动nginx服务
[root@node101.yinzhengjie.org.cn ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 128 :::22 :::*
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nginx
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 :::22 :::*
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
5>.浏览器访问"http://node101.yinzhengjie.org.cn/01.jpg",如下图所示,它并没有显示火影忍者关于人柱力的图片,而是显示了精确匹配的图片,因此我们得出精确匹配优先级高的结论。

三.匹配案例-区分大小写
1>.编写子配置文件
[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/nginx/conf.d/location.conf
server {
listen 80;
server_name node101.yinzhengjie.org.cn; location / {
root /yinzhengjie/data/web/nginx/html/image;
index index.html;
} location ~ /F.?\.JPG {
root /yinzhengjie/data/web/nginx/html;
index index.html;
}
}
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nginx -t
nginx: the configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf test is successful
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
2>.创建测试数据
[root@node101.yinzhengjie.org.cn ~]# cd /yinzhengjie/data/web/nginx/html/
[root@node101.yinzhengjie.org.cn /yinzhengjie/data/web/nginx/html]#
[root@node101.yinzhengjie.org.cn /yinzhengjie/data/web/nginx/html]# ll
total 124
-rw-r--r-- 1 root root 122026 Dec 16 19:35 01.jpg
drwxr-xr-x 2 root root 38 Dec 16 19:35 image
-rw-r--r-- 1 root root 88 Dec 15 23:13 index.html
[root@node101.yinzhengjie.org.cn /yinzhengjie/data/web/nginx/html]#
[root@node101.yinzhengjie.org.cn /yinzhengjie/data/web/nginx/html]# cp 01.jpg Fg.JPG
[root@node101.yinzhengjie.org.cn /yinzhengjie/data/web/nginx/html]#
[root@node101.yinzhengjie.org.cn /yinzhengjie/data/web/nginx/html]# cp 01.jpg Fg.jpg
[root@node101.yinzhengjie.org.cn /yinzhengjie/data/web/nginx/html]#
[root@node101.yinzhengjie.org.cn /yinzhengjie/data/web/nginx/html]# ll
total 364
-rw-r--r-- 1 root root 122026 Dec 16 19:35 01.jpg
-rw-r--r-- 1 root root 122026 Dec 16 20:10 Fg.jpg
-rw-r--r-- 1 root root 122026 Dec 16 20:03 Fg.JPG
drwxr-xr-x 2 root root 38 Dec 16 19:35 image
-rw-r--r-- 1 root root 88 Dec 15 23:13 index.html
[root@node101.yinzhengjie.org.cn /yinzhengjie/data/web/nginx/html]#
3>.重新加载配置文件
[root@node101.yinzhengjie.org.cn ~]# nginx -t
nginx: the configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf test is successful
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ps -ef | grep nginx | grep -v grep
root 4785 1 0 19:36 ? 00:00:00 nginx: master process nginx
nginx 4953 4785 0 20:05 ? 00:00:00 nginx: worker process
nginx 4954 4785 0 20:05 ? 00:00:00 nginx: worker process
nginx 4955 4785 0 20:05 ? 00:00:00 nginx: worker process
nginx 4956 4785 0 20:05 ? 00:00:00 nginx: worker process
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nginx -s reload
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ps -ef | grep nginx | grep -v grep
root 4785 1 0 19:36 ? 00:00:00 nginx: master process nginx
nginx 4953 4785 0 20:05 ? 00:00:00 nginx: worker process is shutting down
nginx 4966 4785 3 20:05 ? 00:00:00 nginx: worker process
nginx 4967 4785 2 20:05 ? 00:00:00 nginx: worker process
nginx 4968 4785 3 20:05 ? 00:00:00 nginx: worker process
nginx 4969 4785 2 20:05 ? 00:00:00 nginx: worker process
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
4>.浏览器输入"http://node101.yinzhengjie.org.cn/Fg.jpg"访问小写字母的url,访问不到,因为"jpg"是小写字母,和咱们配置的nginx规则符合,尽管服务器路径下的确存在该文件依旧是无法访问。

5>.浏览器可以成功访问"http://node101.yinzhengjie.org.cn/Fg.JPG",因为我们写的"JPG"是大写字母,和咱们配置的nginx规则符合

四.匹配案例-不区分大小写
1>.编辑子配置文件
[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/nginx/conf.d/location.conf
server {
listen 80;
server_name node101.yinzhengjie.org.cn; location / {
root /yinzhengjie/data/web/nginx/html/image;
index index.html;
} #区分大小写
#location ~ /F.?\.JPG {
# root /yinzhengjie/data/web/nginx/html;
# index index.html;
#} #不区分大小写
location ~* /F.?\.JPG {
root /yinzhengjie/data/web/nginx/html;
index index.html;
}
}
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nginx -t
nginx: the configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf test is successful
[root@node101.yinzhengjie.org.cn ~]#
2>.重新加载nginx服务
[root@node101.yinzhengjie.org.cn ~]# ps -ef | grep nginx | grep -v grep
root : ? :: nginx: master process nginx
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nginx -t
nginx: the configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf test is successful
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nginx -s reload
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ps -ef | grep nginx | grep -v grep
root : ? :: nginx: master process nginx
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
3>.浏览器输入"http://node101.yinzhengjie.org.cn/Fg.jpg"访问小写字母的url,如下图所示,可以访问到了,因为咱们没有区分URI的大小写

4>.浏览器可以成功访问"http://node101.yinzhengjie.org.cn/Fg.JPG",照样是可以正常访问的
五.匹配案例-URI开始
1>.编辑子配置文件
[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/nginx/conf.d/location.conf
server {
listen ;
server_name node101.yinzhengjie.org.cn; location / {
root /yinzhengjie/data/web/nginx/html;
index index.html;
} location ^~ /static {
root /yinzhengjie/data/web/nginx/html;
index index.html;
}
}
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nginx -t
nginx: the configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf test is successful
[root@node101.yinzhengjie.org.cn ~]#
2>.创建测试数据
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Dec : 01人柱力.jpg
-rw-r--r-- root root Dec : .迪丽热巴.jfif
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# mkdir /yinzhengjie/data/web/nginx/html/static
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cp 01人柱力.jpg /yinzhengjie/data/web/nginx/html/static/.jpg
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cp .迪丽热巴.jfif /yinzhengjie/data/web/nginx/html/static/.jpg
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /yinzhengjie/data/web/nginx/html/static/
total
-rw-r--r-- root root Dec : .jpg
-rw-r--r-- root root Dec : .jpg
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
3>.重新加载nginx配置文件
[root@node101.yinzhengjie.org.cn ~]# ps -ef | grep nginx | grep -v grep
root : ? :: nginx: master process nginx
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nginx -s reload
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ps -ef | grep nginx | grep -v grep
root : ? :: nginx: master process nginx
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
4>.如下图所示,浏览器访问“http://node101.yinzhengjie.org.cn/static/01.jpg”,可以访问成功

5>.如下图所示,浏览器访问“http://node101.yinzhengjie.org.cn/static/02.jpg”,可以访问成功

六.匹配案例-文件名后缀
1>.编辑子配置文件
[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/nginx/conf.d/location.conf
server {
listen ;
server_name node101.yinzhengjie.org.cn; location / {
root /yinzhengjie/data/web/nginx/html;
index index.html;
} location ~* \.(gif|jpg|jpeg|bmp|png|tiff|tif|ico|wmf|js)$ {
root /yinzhengjie/data/web/nginx/static;
index index.html;
}
}
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nginx -t
nginx: the configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /yinzhengjie/softwares/nginx/conf/nginx.conf test is successful
[root@node101.yinzhengjie.org.cn ~]#
2>.创建测试数据
[root@node101.yinzhengjie.org.cn ~]# mkdir /yinzhengjie/data/web/nginx/static
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cp /etc/passwd /yinzhengjie/data/web/nginx/static/passwd.js
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Dec : 01人柱力.jpg
-rw-r--r-- root root Dec : .迪丽热巴.jfif
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cp 01人柱力.jpg /yinzhengjie/data/web/nginx/static/.jpg
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cp .迪丽热巴.jfif /yinzhengjie/data/web/nginx/static/.jpeg
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /yinzhengjie/data/web/nginx/static/
total
-rw-r--r-- root root Dec : .jpg
-rw-r--r-- root root Dec : .jpeg
-rw-r--r-- root root Dec : passwd.js
[root@node101.yinzhengjie.org.cn ~]#
3>.重新加载配置文件
[root@node101.yinzhengjie.org.cn ~]# ps -ef | grep nginx | grep -v grep
root : ? :: nginx: master process nginx
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# nginx -s reload
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ps -ef | grep nginx | grep -v grep
root : ? :: nginx: master process nginx
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
nginx : ? :: nginx: worker process
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
4>.客户端测试访问资源
浏览器访问:http://node101.yinzhengjie.org.cn/01.jpg,如下图所示,访问成功啦

浏览器访问:http://node101.yinzhengjie.org.cn/02.jpeg,如下图所示,范围成功啦

浏览器访问:http://node101.yinzhengjie.org.cn/passwd.js,如下图所示,访问成功啦。

七.匹配案例-优先级
匹配优先级:
=, ^~, ~/~*,/
location优先级:
(location =) > (location 完整路径) > (location ^~ 路径) > (location~,~* 正则顺序) > (location 部分起始路径) > (/)
八.生产使用案例
#直接匹配网站根会加速Nginx访问处理:
location = / {
......;
}
location / {
......;
}
#静态资源配置:
location ^~ /static/ {
......;
}
# 或者
location ~* \.(gif|jpg|jpeg|png|css|js|ico)$ {
......;
}
#多应用配置
location ~* /app1 {
......;
}
location ~* /app2 {
......;
}
Nginx 核心配置-location的匹配案例实战篇的更多相关文章
- Nginx 核心配置-location的登录账户认证实战篇
Nginx 核心配置-location的登录账户认证实战篇 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.使用ab命令模拟网站攻击 1>.安装httpd-tools工具 ...
- Nginx 核心配置-根目录root指令与别名alias指令实战案例
Nginx 核心配置-根目录root指令与别名alias指令实战案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.试验环境说明 1>.虚拟机环境说明 [root@nod ...
- Nginx 核心配置-新建一个web站点
Nginx 核心配置-新建一个web站点 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Nginx基础配置常用参数说明 [root@node101.yinzhengjie.or ...
- Nginx 核心配置-检测文件是否存在
Nginx 核心配置-检测文件是否存在 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. try_files会按顺序检查文件是否存在,返回第一个找到的文件或文件夹(结尾加斜线表示为文件 ...
- Nginx 核心配置-作为上传服务器配置
Nginx 核心配置-作为上传服务器配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.关键参数说明 client_max_body_size 1m: 设置允许客户端上传单 ...
- Nginx 核心配置-自定义错误页面
Nginx 核心配置-自定义错误页面 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 生产环境中错误页面一般都是UI或开发工程师提供的,他们已经在软件中定义好了,我们这里就简单写个h ...
- Nginx 核心配置-可优化配置参数
Nginx 核心配置-可优化配置参数 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.nginx的官网查看指令帮助信息方法 1>.打开nginx的官网(https://ng ...
- Nginx 核心配置-作为下载服务器配置
Nginx 核心配置-作为下载服务器配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.无限速版本的下载服务器 1>.查看主配置文件 [root@node101.yinz ...
- Nginx 核心配置-长连接配置
Nginx 核心配置-长连接配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.长连接配置参数说明 keepalive_timeout number; 设定保持连接超时时长,0 ...
随机推荐
- Excel-信息函数&数组公式
1.IS系列函数-逻辑函数 is函数是一个逻辑函数,可以用来判断一些特定的内容 Istext判断单元格是否是文本 Isnumber判断单元格是否为数值 Istext和isnumber的判断的结果相反 ...
- cf1039D 分块
cf1039D 链接 cf 思路 一次k可以贪心O(n)算. 对于\(≤\sqrt{n}\)的k,暴力算. 对于\(>\sqrt{n}\)的k,最多会有\(\sqrt{n}\)种答案,而且答案单 ...
- 数据结构or算法
其实长久以来 mrxfyxj一直纠结着数据结构和算法到底有什么区别 只要学了一个算法就在惋惜她为什么不能是数据结构 产生这种想法的原因是mrxf觉得他blog里数据结构的东西很少 而mrxf自身又有一 ...
- 简析平衡树(四)——FHQ Treap
前言 好久没码过平衡树了! 这次在闪指导的指导下学会了\(FHQ\ Treap\),一方面是因为听说它可以可持久化,另一方面则是因为听说它是真的好写. 简介 \(FHQ\ Treap\),又称作非旋\ ...
- A1083 List Grades (25 分)
Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...
- Deepin (Linux Debian)使用日记
(现在Deepin使用了debian的stable源,如果求新,推荐使用排行榜前三的Linux发行版——> Manjaro) 修复开启混合显卡驱动后,屏幕泛白偏灰问题“: https://blo ...
- java8之行为参数化
今天看到一块switch代码,觉得又臭又长,可以优化一下,只需要将函数名作为入参进行改造,有点类似于策略模式. 以下是使用Java8进行行为参数化的简单案例: User.java import lom ...
- [HDU4867]Xor (线段树分治+类数位dp)
[HDU4867]Xor (线段树分治+类数位dp) 提供一种\((m+n) log a log m\)带有常数约\(\frac{1}{log n}\)的算法 处理询问,将后来加入的数算进序列中,则每 ...
- Kubernetes Dashboard 安装与认证
1.安装dashboard $ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/ ...
- (十六)golang--匿名函数
Go支持匿名函数,如果我们某个函数只是使用一次,可以考虑使用匿名函数,匿名函数也可以实现多次调用: 匿名函数的使用方式:(1)在定义匿名函数的时候就直接调用,这种方式匿名函数只调用一次: (2)将匿名 ...