Skip to content

Instantly share code, notes, and snippets.

@zufrieden
Created November 4, 2014 07:46
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 zufrieden/afa274492a4629f88aa2 to your computer and use it in GitHub Desktop.
Save zufrieden/afa274492a4629f88aa2 to your computer and use it in GitHub Desktop.
Nginx Config
#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 logs/access.log main;
client_max_body_size 100M;
sendfile on;
#tcp_nopush on;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
index index.php index.html index.htm;
autoindex on;
server {
#Drupal configuration http://wiki.nginx.org/Drupal
client_max_body_size 100M;
listen *:8001;
server_name localhost local *.dev;
root /Users/mfh/Sites/$host/; ## <-- the only path reference.
access_log off; # <--- on my personal dev machine
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root html;
#}
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)$ {
allow 192.168.0.0/16;
deny all;
}
location ~ \..*/.*\.php$ {
return 403;
}
location / {
# This is cool because no php is touched for static content
try_files $uri $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;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#uncoment to use xhprof
#fastcgi_param PHP_VALUE "auto_prepend_file=/Users/simon/Sites-src/xhprof/external/header.php";
fastcgi_pass 127.0.0.1:9009;
fastcgi_intercept_errors on;
#fastcgi_pass unix:/tmp/phpfpm.sock;
}
# 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;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
server {
listen *:8002;
server_name *.dev;
root /Users/mfh/Sites/$host/; ## <-- the only path reference.
access_log off; # <--- on my personal dev machine
# strip app.php/ prefix if it is present
#rewrite ^/app\.php/?(.*)$ /$1 permanent;
location / {
index app.php;
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9009
location ~ \.php($|/) {
fastcgi_pass 127.0.0.1:9009;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
fastcgi_read_timeout 600;
}
}
server {
listen *:8003;
server_name *.dev;
root /Users/mfh/Sites/$host/; ## <-- the only path reference.
access_log off; # <--- on my personal dev machine
location / {
try_files $uri $uri/ /index.php?$args /index_dev.php?$args;
}
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9009
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9009;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
}
server {
listen *:8004; ## Bolt CMS
server_name *.dev;
root /Users/mfh/Sites/$host/; ## <-- the only path reference.
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* /thumbs/(.*)$ {
try_files $uri $uri/ /app/classes/timthumb.php?$query_string;
}
location /app/classes/upload {
try_files $uri $uri/ /app/classes/upload/index.php?$query_string;
}
location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff)$ {
access_log off;
expires 30d;
add_header Pragma public;
add_header Cache-Control "public, mustrevalidate, proxy-revalidate";
}
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9009;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
location ~ /\.ht {
deny all;
}
location /app {
deny all;
}
location ~ /vendor {
deny all;
}
location ~ \.db$ {
deny all;
}
}
server {
listen *:8005; # okado
server_name *.dev;
root /Users/mfh/Sites/$host/; ## <-- the only path reference.
access_log off; # <--- on my personal dev machine
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
# set a nice expire for assets
location ~* "^.+\.(jpe?g|gif|css|png|js|ico|pdf|zip|tar|t?gz|mp3|wav|swf)$" {
expires max;
add_header Cache-Control public;
}
# the downloader has its own index.php that needs to be used
location ~* ^(/downloader|/js|/404|/report)(.*) {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$1/index.php$1;
fastcgi_read_timeout 600;
fastcgi_pass 127.0.0.1:9009;
}
location ~* \.php {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 600;
fastcgi_pass 127.0.0.1:9009;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment