Nginx redirect requests to sub-domains that do not exist to custom 404 page when wild card A record is set?

Posted by Anagio on Server Fault See other posts from Server Fault or by Anagio
Published on 2011-11-20T21:01:23Z Indexed on 2011/11/21 1:54 UTC
Read the original article Hit count: 462

Filed under:

Is there a way to capture all requests to arbitrary sub-domains which do not have a virtual host setup, and redirect to a custom 404 page in nginx? I will have a wild card A record setup *.example.com and all our users will have a sub-domain username.example.com. If someone enters a sub-domain which does not exist how can I redirect to a custom 404 page rather than have it resolve since wild card is setup?

© Server Fault or respective owner

Related posts about nginx