Skip to content

Instantly share code, notes, and snippets.

@ollym
Created February 23, 2011 19:14
Show Gist options
  • Save ollym/840965 to your computer and use it in GitHub Desktop.
Save ollym/840965 to your computer and use it in GitHub Desktop.
user www-data;
worker_processes 4;
error_log /var/log/nginx/nginx.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
}
http {
include fastcgi.conf;
include mime.types;
default_type application/octet-stream;
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
## Proxy
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
## Compression
gzip on;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
### TCP options
tcp_nodelay on;
tcp_nopush on;
keepalive_timeout 65;
sendfile on;
server {
server_name _ "";
access_log /var/log/nginx/$host.access.log;
error_log /var/log/nginx/error.log;
root /var/www;
index index.php index.html;
## Block bad bots
if ($http_user_agent ~* (HTTrack|HTMLParser|libcurl|discobot|Exabot|Casper|kmccrew|plaNETWORK|RPT-HTTPClient)) {
return 444;
}
## Deny dot files:
location ~ /\. {
deny all;
}
## Favicon Not Found
location = /favicon.ico {
access_log off;
log_not_found off;
}
## Robots.txt Not Found
location = /robots.txt {
access_log off;
log_not_found off;
}
location / {
index index.php index.html index.htm;
try_files $uri $uri/ index.php$uri?$args;
}
location ~ ^(.+\.php)(.*)$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
}
### NginX Status
location /nginx_status {
stub_status on;
access_log off;
}
### FPM Status
location ~ ^/(status|ping)$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
access_log off;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment