Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a number of vhosts, and I'd like to "turn off" the default vhost, either by blank page, error page, or generally whatever is the most efficient use of Nginx's resources, whilst only allowing other vhosts to be access via pre-defined domains.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Define a default_server that returns an HTTP 444 code:

server {
    listen      80 default_server;
    server_name _;
    return      444;
}

(Returning a 4xx error code means requests can be interpreted by a client as an unsuccessful request, rather an HTTP 200 Blank Page But Totally Worked Trust Me.)

share|improve this answer

Just define default vhost that will point to directory with blank index.html file.

server {
    listen       80 default_server;
    server_name  _ ;
    root /var/www/placeholder ; 
    index index.html;
}

and place blank index in /var/www/placeholder

share|improve this answer
    
it will catch every request that does not hit any of your domainnames and response with blank page. –  wojciechz Aug 23 '12 at 9:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.