Skip to content

Instantly share code, notes, and snippets.

@neonstalwart
Last active December 15, 2015 10:29
Show Gist options
  • Save neonstalwart/5246494 to your computer and use it in GitHub Desktop.
Save neonstalwart/5246494 to your computer and use it in GitHub Desktop.
my nginx *.dev config - the first line in each file is the full path to the file because gists don't give enough context. see https://gist.github.com/neonstalwart/5246908 for some extra config for virtualbox (not included here because it's ugly)
# /usr/local/etc/nginx/common
index index.html index.htm index.json;
if_modified_since before;
location ~ /\.(svn|git|ht) {
deny all;
}
location ~ \.svgz$ {
add_header Content-Encoding gzip;
}
location ~ \.(?:woff|ttf|otf|svgz)$ {
expires max;
}
gzip on;
gzip_comp_level 9;
gzip_min_length 128;
gzip_types text/javascript text/css application/x-javascript application/javascript application/json;
gzip_vary on;
gzip_proxied any;
# /usr/local/etc/dnsmasq.d/debug
#log-facility=/usr/local/var/log/dnsmasq/logs
#log-dhcp
#log-queries
# /usr/locar/etc/nginx/sites-enabled/dev
# Catch any request for *.dev
server {
listen 80;
server_name *.dev;
root /Users/neonstalwart/Hosts/$host;
include common;
autoindex on;
location / {
try_files $uri $uri/ =404;
}
}
include /Users/neonstalwart/Hosts/*.nginx;
# /usr/local/etc/dnsmasq.d/dev
# *.dev DNS resolution
listen-address=127.0.0.1
address=/.dev/127.0.0.1
# /etc/resolver/dev
nameserver 127.0.0.1
port 53
domain dev
search_order 1
# /usr/local/etc/dnsmasq.conf
conf-dir=/usr/local/etc/dnsmasq.d
# /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.dnsmasq</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/sbin/dnsmasq</string>
<string>--keep-in-foreground</string>
</array>
<key>KeepAlive</key>
<dict>
<key>NetworkState</key>
<true/>
</dict>
</dict>
</plist>
# /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.nginx</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/nginx/sbin/nginx</string>
<string>-g</string>
<string>daemon off;</string>
</array>
<key>WorkingDirectory</key>
<string>/usr/local</string>
</dict>
</plist>
# /usr/local/etc/nginx/nginx.conf
worker_processes 2;
pid /usr/local/var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /usr/local/etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /usr/local/var/log/nginx/access.log;
error_log /usr/local/var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# SSL
##
# server {
# listen 443 default_server ssl;
# ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
# ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
# }
##
# Virtual Host Configs
##
include /usr/local/etc/nginx/sites-enabled/*;
}
# ~/Hosts/voro.dev.nginx
# server for voro.dev
server {
server_name voro.dev;
location /static {
try_files /Users/neonstalwart/code/voro/voro-server/release/$uri /Users/neonstalwart/code/voro/voro-server/src/$uri =404;
}
location / {
try_files $uri @node;
}
location @node {
proxy_set_header X-Forwarded-Host $http_host;
proxy_pass http://localhost:8082;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment