Nginx wildcard virtualhost

wildcard virtual host allow you to host multiple web sites with one configuration file.

Here is what i use for bizhat.com free hosting sub domains.

server {
    listen   167.114.61.119:80;
    server_name *.bizhat.com;
    autoindex on;
    access_log /var/log/nginx/free_access.log;
    error_log /var/log/nginx/free_error.log;
    root /home/vhosts/$host;

    index index.html index.htm default.htm default.html;

    location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
        access_log off;
        expires max;
    }

    location ~ /\.ht {
        deny  all;
    }

    error_page 302  /302.html;
    location = /302.html {
        root  /home/free.bizhat.com/error;
    }

    error_page 404 /404.html;
    location = /404.html {
          root  /home/free.bizhat.com/error;
    }
}

Advertisement

Add a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Advertisement