nginx - nginx:if条件中的“allow”指令
问题描述
我的网络应用程序根据子域加载不同的视图,并且子域是动态的,所以我像这样启动虚拟主机配置:
server {
listen 443 ssl http2 default_server;
server_name ~^(?<subdomain>.+)\.test\.com$;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
...
}
稍后在 server 指令中,我指定了访问控制:
location / {
root /usr/share/webapp/;
index /index.html;
try_files $uri $uri/ =404;
allow my.ip.sub.net/24;
deny all;
}
现在我想公开某些子域。试试这个:
location / {
root /usr/share/webapp/;
index /index.html;
try_files $uri $uri/ =404;
allow my.ip.sub.net/24;
if ($subdomain = publicenv) {
allow all;
}
deny all;
}
给我这个错误信息:
nginx: [emerg] "allow" directive is not allowed here in /etc/nginx/conf.d/https.conf:119
甚至可以根据变量动态加载白名单选项吗?
解决方案
推荐阅读
- laravel - 从 Laravel 的数据库中获取 email_verified 检查条件数据
- ios - React-Native:错误:无法为 iOS 项目安装 CocoaPods 依赖项,这是此模板所需的
- android - 帆布?或 View.onDraw() 方法中的 Canvas
- mysql - “字段列表”中的未知列“u.MemberId”
- algorithm - 随机森林的可能算法
- excel - VBA - 自动工作表保护丢失密码
- css - 一列固定宽度的 HTML 表格,其他列流动且等宽
- python - 如何为 Android repo 工具实现 git hook
- ios - 维护 TableView 之间的数组顺序?
- nativescript - paymentAuthorizationViewControllerDidAuthorizePaymentHandler 中的 Nativescript 为空 PKPayment