Skip to content

Instantly share code, notes, and snippets.

@kvz
Created November 30, 2010 12:35
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 kvz/721617 to your computer and use it in GitHub Desktop.
Save kvz/721617 to your computer and use it in GitHub Desktop.
A default Nginx config file that will server any (cake) php site in /var/www/*
server {
listen 80 default;
server_name _;
set $site $host;
if ($site ~ "^(w{3}\.)?(.*)$") { set $site $2; }
set $root /var/www/$site;
if (-d /var/www/www.$site) { set $root /var/www/www.$site; }
if (!-d $root) { rewrite ^(.*)$ http://decomissioned.plutonia.nl$1 break; }
if (-d $root/app) { set $root $root/app; }
if (-d $root/webroot) { set $root $root/webroot; }
access_log /var/log/nginx/$site.access.log;
root $root;
index index.html index.htm index.php;
if ($site = 'kvzlib.net') {
rewrite ^/b/(.+)$ /get.php?file=bash/programs/$1.sh last;
}
if (!-f $request_filename) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ (\.php|sitemap\.xml)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
include fastcgi_params;
}
location ~ ^/(favicon\.ico$|img|images|css|js|ccss|cjs) {
access_log off;
expires 370d;
add_header Cache-Control public;
}
# deny access to hidden
location ~ /\. {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment