Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to match multiple conditions using nginx

Shulou Source: shulou.com Published: 2022-06-02 00:22:24 09月28日 Update

How do I match multiple conditions using nginx? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.

Treatment method

Demand

Here you need to match $remote_addr $http_x_forwarded_for, one of which is an internal ip to access.

Configure nginx

$remote_addr does not match $flag is 01 and flag is 011. Finally, 403 is returned.

Set $flag 0 flag if ($remote_addr! ~ (127.0.0.1)) {set $flag "${flag} 1";} if ($http_x_forwarded_for! ~ (127.0.0.1)) {set $flag "${flag} 1";} if ($flag = "011") {return 403;} will it help you to read the above? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Demand help multiple conditions clarity content for this articles beginners methods more knowledge industry information information channels problems channels one processing learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL OPPO Reno MariaDB NVidia macOS