Like everyone else, I read ezra's nginx config and put it straight to use.
After recently becoming addicted to yslow, tweaking configs day and night (well, it happened once. yslow is great though) I decided to add expires headers to anything that isn't served by rails, your js, css, images etc.
Without further ado, my config:
worker_processes 2;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include conf/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx_access.log main;
error_log /var/log/nginx_error.log debug;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
gzip on;
gzip_http_version 1.0;
# More is heavier on the CPU
gzip_comp_level 5;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
upstream schwarz {
server 127.0.0.1:4000;
server 127.0.0.1:4001;
server 127.0.0.1:4002;
}
server {
listen 80;
client_max_body_size 50M;
server_name .germanforblack.com;
root /var/www/public;
access_log /var/log/nginx.vhost.access.log main;
location / {
proxy_set_header X-Real-IP $remote_addr;
# needed for HTTPS
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
proxy_max_temp_file_size 0;
if (-f $request_filename) {
expires max;
break;
}
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
# Tasty caching
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://schwarz;
break;
}
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /var/www/public;
}
}
}
Note the expires method. You just sped up your app dramatically
1 Nate Clark // Oct 05, 2007 at 04:20 AM
2 Ben Schwarz // Oct 06, 2007 at 02:50 AM