Last active
March 11, 2016 09:05
-
-
Save iolloyd/610dc489ff4309a668e6 to your computer and use it in GitHub Desktop.
Dynamic hosts using dnsmasq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
index index.php; | |
set $base "/var/www"; | |
set $domain $host; | |
# Simple | |
if ($domain ~ "^(.[^.]*)\.loc$") { | |
set $domain $1; | |
set $rootpath "${domain}"; | |
set $servername "${domain}.loc"; | |
} | |
# Multi | |
if ($domain ~ "^(.*)\.(.[^.]*)\.loc$") { | |
set $subdomain $1; | |
set $domain $2; | |
set $rootpath "${domain}/${subdomain}/www/"; | |
set $servername "${subdomain}.${domain}.loc"; | |
} | |
server_name $servername; | |
access_log "/var/log/nginx/${servername}.access.log"; | |
error_log "/var/log/nginx/${servername.error.log"; | |
root $base/$rootpath; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $request_filename; | |
include fastcgi_params; | |
fastcgi_param PATH_INFO $fastcgi_script_name; | |
fastcgi_buffer_size 128k; | |
fastcgi_buffers 256 4k; | |
fastcgi_busy_buffers_size 256k; | |
fastcgi_temp_file_write_size 256k; | |
fastcgi_intercept_errors on; | |
} | |
location ~ /\.git { | |
deny all; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
echo "address=/.dev/127.0.0.1" >> /etc/dnsmasq.conf