Chinaunix

标题: [Nginx] Nginx配置文件中map模块的正则表达式怎么理解? [打印本页]

作者: ccnupq    时间: 2016-09-07 00:05
标题: [Nginx] Nginx配置文件中map模块的正则表达式怎么理解?
本帖最后由 ccnupq 于 2016-09-07 00:07 编辑

## 这里取得原始用户的IP地址
map $http_x_forwarded_for  $clientRealIp {
""        $remote_addr;
~^(?P<firstAddr>[0-9\.]+),?.*$        $firstAddr;  <====多个IP, 逗号分隔, 提取第一个IP, 这个正则表达式怎么样理解?
}

## 针对原始用户 IP 地址做限制
limit_conn_zone $clientRealIp zone=TotalConnLimitZone:20m ;
limit_conn  TotalConnLimitZone  50;
limit_conn_log_level notice;





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2