Skip to content

Instantly share code, notes, and snippets.

@carlosfilho88
Last active October 6, 2015 12:48
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save carlosfilho88/2996456 to your computer and use it in GitHub Desktop.
Save carlosfilho88/2996456 to your computer and use it in GitHub Desktop.
Zend with nginx
## Force redirect to www address
server {
server_name zf.local;
rewrite ^(.+?)/?$ http://www.zf.local$1 permanent;
}
server {
listen 80;
server_name www.zf.local;
index index.php;
charset utf-8;
keepalive_requests 100;
root /home/cf/workspace/zf/public;
access_log /var/log/nginx/zf/access.log;
error_log /var/log/nginx/zf/error.log;
# remove trailing slash, that throws ZF router
rewrite ^/(.*)/$ /$1 permanent;
location ~ /\.ht {
deny all;
}
location = /favicon.ico {
return 204;
access_log off;
log_not_found off;
}
## Expires headers on known filetypes
location ~* \.(ico|css|js|gif|jpg|jpeg|png|swf|pdf|html)$ {
access_log off;
log_not_found off;
expires 10s; #1h, 10m, 1d, 1w, max
break;
}
## Enable robots.txt
location = /robots.txt {
rewrite (.*) /robots/robots.txt;
break;
}
## Enable sitemap.xml
location = /sitemap.xml {
rewrite (.*) /downloads/sitemap.xml;
break;
}
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
return 444;
}
if ($http_user_agent ~* LWP::Simple|BBBike|wget|msnbot|scrapbot|Baiduspider|Jullo) {
return 403;
}
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_ignore_client_abort on;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment