Skip to content

Instantly share code, notes, and snippets.

@LateButEarly
Forked from GiovanniK/nginx-vhost
Last active August 29, 2015 14:12
Show Gist options
  • Save LateButEarly/1485fe840d160b639ffa to your computer and use it in GitHub Desktop.
Save LateButEarly/1485fe840d160b639ffa to your computer and use it in GitHub Desktop.
fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=Nginx:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
server {
listen 80;
server_name nginx.dev;
access_log /var/log/nginx/nginx.access.log;
root /var/www/nginx.dev/public/;
index index.html index.php;
# Don't cache rules
if ($request_uri ~* "/(folder/|file.php)")
{
set $no_cache 1;
}
# PHP FPM
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_cache Nginx;
fastcgi_cache_valid 200 5m;
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
add_header X-Cache $upstream_cache_status;
}
# Cache static files such as images, styles and scripts
location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
expires 60m;
}
# Health test
if ($request_uri ~* "^/ok$") {
return 200;
}
# Block all svn access
if ($request_uri ~* "/\.svn") {
return 404;
}
# Block all git access
if ($request_uri ~* "/\.git") {
return 404;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment