I actually have a working regular expression which should work now: server_name ^(?!web3\.)(?<account>.+)\.mydomain\.com$; But for some odd reason when I restart nginx, I am getting: nginx: [emerg] unknown "account" variable This should work though, right? Posted at Nginx Forum: http://forum.nginx.org/read.php?2,236870,236876#msg-236876