Skip to content

Instantly share code, notes, and snippets.

@omega8cc
Created January 25, 2012 18:44
Show Gist options
  • Save omega8cc/1677848 to your computer and use it in GitHub Desktop.
Save omega8cc/1677848 to your computer and use it in GitHub Desktop.
#######################################################
### nginx compact basic configuration start
#######################################################
###
### deny crawlers and bots without 403 response
###
if ($http_user_agent ~* (HTTrack|HTMLParser|libwww|wget|AutomaticSiteMap|bot) ) {
return 444;
}
###
### catch all unspecified requests
###
location / {
try_files $uri @dynamic;
}
###
### send all not cached requests to php-fpm with clean URLs support
###
location @dynamic {
rewrite ^/(.*)$ /index.html last;
}
###
### send all non-static requests to php-fpm
###
location ~ \.php$ {
try_files $uri @dynamic; ### check for existence of php file first
fastcgi_pass 127.0.0.1:9000; ### php-fpm listening on port 9000
}
###
### serve & no-log static files & images directly
###
location ~* ^.+\.(css|js|xml|jpg|jpeg|gif|png|ico|swf|pdf|doc|xls|tiff|tif|txt|shtml|cgi|bat|pl|dll|asp|exe|class|htm|html)$ {
access_log off;
expires 30d;
try_files $uri =404;
}
###
### serve & log bigger media/static/archive files directly
###
location ~* ^.+\.(avi|mpg|mpeg|mov|wmv|mp3|mp4|m4a|flv|wav|midi|zip|gz|rar)$ {
expires 30d;
try_files $uri =404;
}
#######################################################
### nginx compact basic configuration end
#######################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment