mak*_*sek 5 ssl nginx ssl-certificate
我只需要为来自我们 Intranet 外部的请求启用客户端证书验证,而不需要验证来自例如 192.168.0.0/24 的请求。我尝试使用geo
模块为内部子网定义变量。在http
上下文中:
geo $intranet {
default 0;
192.168.0.0/24 1;
}
Run Code Online (Sandbox Code Playgroud)
在server
上下文中
if ($intranet != 1) {
ssl_verify_client on;
}
Run Code Online (Sandbox Code Playgroud)
但不可能ssl_verify_client
在if
语句内使用指令。我收到一个错误:
此处不允许使用“ssl_verify_client”指令
有没有其他方法可以做到这一点?
最后我找到了按预期工作的解决方案。
在http
上下文中:
geo $intranet {
default 0;
192.168.0.0/23 1;
}
Run Code Online (Sandbox Code Playgroud)
在server
上下文中:
ssl_verify_client optional;
set $verify $intranet$ssl_client_verify;
if ($verify ~ (0NONE|0FAILED)) {
return 403;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1563 次 |
最近记录: |