Skip to content

Instantly share code, notes, and snippets.

@abovedave
Created September 20, 2018 23:01
Show Gist options
  • Save abovedave/a36e7f2659bb56dba442dd08d4ec36a1 to your computer and use it in GitHub Desktop.
Save abovedave/a36e7f2659bb56dba442dd08d4ec36a1 to your computer and use it in GitHub Desktop.
nginx .test domains locally
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
access_log /Users/Dave/Sites/access.log;
error_log /Users/Dave/Sites/error.log warn;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name app localhost .test;
set $basepath "/Users/Dave/Sites";
set $domain $host;
if ($domain ~ "^(.*)\.test$") {
set $domain $1;
}
set $rootpath "${domain}";
if (-d $basepath/$domain/) {
set $rootpath "${domain}/";
}
if (-f $basepath/$domain/index.html) {
set $rootpath $domain;
}
root $basepath/$rootpath;
index index.html index.htm index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
include servers/*;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment