Anyone can help me to combine these 2 lines?

I just want to set…if $http_user_agent equals AAA or BBB or empty
("")…then return 400…Thanks…

if ($http_user_agent ~ (AAA|BBB)) {return 400;}
if ($http_user_agent = "") {return 400;}

Posted at Nginx Forum:,87266,87266#msg-87266

Try this:

if ($http_user_agent ~ “^(AAA|BBB|^.+)$”) {return 400;}

^.+ ??
It means empty string?

Posted at Nginx Forum:,87266,87283#msg-87283

^(not).+(one or more of anything)

Can I write like this…?

if ($http_user_agent ~ (AAA|BBB|^$)) {return 400;}

Posted at Nginx Forum:,87266,87285#msg-87285

Yeah, that should work.