Skip to content

Instantly share code, notes, and snippets.

@janoka
Last active March 20, 2017 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janoka/934866485e3f9c3bad694d87b918f6c0 to your computer and use it in GitHub Desktop.
Save janoka/934866485e3f9c3bad694d87b918f6c0 to your computer and use it in GitHub Desktop.
# Location: /usr/local/etc/nginx/sites-available/dev.conf
# Run: ln -s /usr/local/etc/nginx/sites-available/dev.conf /usr/local/etc/nginx/sites-enabled/dev.conf
server {
listen 80;
server_name ~^(?<sitename>.+\.dev)$;
root /Users/__username__/www/$sitename.dev;
# access_log /usr/local/var/log/nginx/$sitename.dev.access.log;
access_log off;
error_log /usr/local/var/log/nginx/$sitename.dev.error.log;
# error_log off;
include /usr/local/etc/nginx/conf.d/drupal-7.conf;
}
# NGINX webserver Drupal 7. config.
# See: http://wiki.nginx.org/Drupal
index index.html index.php;
location ~ /\.ht {
deny all;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# This matters if you use drush
location = /backup {
deny all;
}
# Very rarely should these ever be accessed outside of your lan
location ~* \.(txt|log)$ {
deny all;
}
location ~ \..*/.*\.php$ {
return 403;
}
location / {
# This is cool because no php is touched for static content
try_files $uri @rewrite;
}
location @rewrite {
# Some modules enforce no slash (/) at the end of the URL
# Else this rewrite block wouldn't be needed (GlobalRedirect)
rewrite ^/(.*)$ /index.php?q=$1;
}
# Php settings.
include /usr/local/etc/nginx/conf.d/php-fpm.conf;
# Fighting with ImageCache? This little gem is amazing.
location ~ ^/sites/.*/files/imagecache/ {
try_files $uri @rewrite;
}
# Catch image styles for D7 too.
location ~ ^/sites/.*/files/styles/ {
try_files $uri @rewrite;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
# log_not_found off;
}
# Location: /usr/local/etc/nginx/conf.d/php-fpm.conf
# NGINX configuration file for PHP-FPM
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# Location: /usr/local/etc/nginx/conf.d/xhprof.conf
# NGINX configuration for xhprof.
location ^~ /xhprof_html/ {
root /usr/local/Cellar/php56-xhprof/254eb24/xhprof_html/;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/Cellar/php56-xhprof/254eb24$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9001;
location ~ ^.*\.(css|js|gif)$ {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment