摘要: server { listen 38090; access_by_lua_block { local require = require local ipmatch = require("resty.ipmatcher") local ip, err = ipmatch.new({ "192.168 阅读全文
posted @ 2022-09-15 15:09 白--茶 阅读(63) 评论(0) 推荐(0) 编辑
摘要: request_uri request_uri: full original request URI (with arguments) - 请求的整个生命周期里不会变化 - 携带原始参数的完整的uri uri uri: current URI in request, normalized The v 阅读全文
posted @ 2022-08-03 22:56 白--茶 阅读(632) 评论(0) 推荐(0) 编辑
摘要: command + shift + p >shell command: install 'code' command in PATH 阅读全文
posted @ 2022-07-12 20:52 白--茶 阅读(536) 评论(0) 推荐(0) 编辑
摘要: mirror 流量复制 Nginx的 mirror 指令来自于 ngx_http_mirror_module 模块 Nginx Version > 1.13.4 mirror 指令提供的核心功能就是流量复制, 至于流量复制要用来干嘛,这个就各取所需了。 先看一段示例配置: location / { 阅读全文
posted @ 2022-05-11 20:42 白--茶 阅读(511) 评论(0) 推荐(0) 编辑
摘要: Nginx反向代理websocket 示例: http { map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { ... location /chat/ { proxy_pass http://ba 阅读全文
posted @ 2022-05-10 11:39 白--茶 阅读(1351) 评论(0) 推荐(0) 编辑
摘要: map指令简单介绍 当然这里写的都是官方文档是已经写过的,我简单抄一下哈。 map指令来自于 ngx_http_map_module 模块,提供的核心能力是 基于一个变量创建一个新变量,大概是这意思。 语法: 只能配置在http块内 map string $variable {...} 直接看这个语 阅读全文
posted @ 2022-05-08 23:05 白--茶 阅读(2795) 评论(0) 推荐(2) 编辑
摘要: 说一段废话 压缩响应数据有什么作用呢?问的好:从用户体验和IT成本两方面回答这个问题: 用户体验上 网速一定的情况下,传输5MB数据比传输10MB数据的时间快了一半。所以传输数据越小用户加载页面就越快,当然相比较之下体验会更好。 IT成本上 对这个场景来说的成本主要是带宽成本, 数据不压缩那么传输这 阅读全文
posted @ 2022-05-08 16:03 白--茶 阅读(681) 评论(3) 推荐(1) 编辑
摘要: 基于POST请求体中的某个参数限流 背景 电商平台有活动,活动涉及优惠券的抢券,优惠券系统对大并发支持略差,为了保护整体系统平稳,因此在入口Nginx层对抢券接口做了一层限流。 完整实现如下: lua_shared_dict my_limit_req_store 100m; server { lis 阅读全文
posted @ 2022-05-07 21:19 白--茶 阅读(358) 评论(1) 推荐(1) 编辑
摘要: 1. 先说问题 某天晚上9点左右正是业务高峰期,我们有台Nginx触发了响应状态码异常的告警,大量502。登录机器查看error log 输出的都是 Cannot assign requested address # 不能分配请求地址 2. 解决方案 [root@node-1 ~]# cat /et 阅读全文
posted @ 2022-04-18 20:24 白--茶 阅读(1152) 评论(0) 推荐(0) 编辑
摘要: Nginx -t 检测语法时很慢怎么办? [root@node-2 ~]# time nginx -t nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok nginx: confi 阅读全文
posted @ 2022-04-18 11:20 白--茶 阅读(265) 评论(0) 推荐(0) 编辑