How to match multiple conditions using nginx
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.