NGINX不等于 [英] NGINX not equal to

查看:129
本文介绍了NGINX不等于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除非http_user_agent = xxx,否则客户希望我阻止对该页面的访问.

A client wants me to block access to a page unless the http_user_agent = xxx.

有没有办法做到这一点?我在想if elseif not函数,但这似乎不存在.

Is there a way to do this? I was thinking of an if else or if not function but this doesn't seem to exist.

如果我想阻止用户代理,可以执行以下操作,但是有一种方法只能允许该用户代理吗?

If I wanted to block a user agent I could do the below but is there a way to only allow that user agent?

if ($http_user_agent ~* (xxx) ) {
   return 403; 
}

推荐答案

使用!~*运算符,它是~*的否定版本.

Use the !~* operator which is the negated version of ~*.

有关详细信息,请参见此文档.

See this document for details.

这篇关于NGINX不等于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆