map $host $subdomain { ~^(?P.+)\.{{ domain_segments|join("\\.") }}$ $sub; } server { listen 80; server_name *.{{ domain_segments|join(".") }}; root /var/www/repos/$subdomain; location = / { autoindex on; } location / { try_files $uri $uri/ /index.html; index index.html index.htm; if (!-e $request_filename) { return 404; } } location ~ /\.git { deny all; return 404; } }