NGINX不等于

编程入门 行业动态 更新时间:2024-10-22 07:35:45
本文介绍了NGINX不等于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

有没有办法做到这一点?我在想if else或if 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不等于

本文发布于:2023-11-15 21:36:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598163.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不等于   NGINX

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!