Shane Madden's answer will work, or you may also use the non-standard response code 444, which will kill the connection without sending any headers (source: http://wiki.nginx.org/HttpRewriteModule)
To block specific subdomains:
server {
server_name subdomain.example.com;
return 444;
}
Or to block all subdomains or domains that are not handled elsewhere:
server {
server_name _;
return 444;
}
The latter option is useful when blocking domains that are duplicating your content and thus may hurt your search engine rankings. (This comes from personal experience.)
Or, if you wanted to drop all traffic that wasn't to a domain explicitly defined in another
server
block in your config:Shane Madden's answer will work, or you may also use the non-standard response code 444, which will kill the connection without sending any headers (source: http://wiki.nginx.org/HttpRewriteModule)
To block specific subdomains:
Or to block all subdomains or domains that are not handled elsewhere:
The latter option is useful when blocking domains that are duplicating your content and thus may hurt your search engine rankings. (This comes from personal experience.)
If your subdomain have trafic, better redirect all request from subdomain to domain like this
in server section
It's SEO friendly.