set $h site1.ru;
include defaults-server
set $h site2.ru;
include defaults-server
----
defaults-server
server {
server_name $h www.$h
include locations;
location / {return 406;}
}
---
locations
error_page 406 @bckend;
location @bckend{
proxy_pass ...
....
}