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:

Try this:

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

^.+ ??
It means empty string?

Posted at Nginx Forum:

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

Can I write like this…?

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

Posted at Nginx Forum:

Yeah, that should work.