proxy_cache ramdisk
Ryan Malayter
malayter at gmail.com
Mon Feb 1 17:13:34 MSK 2010
On Sun, Jan 31, 2010 at 9:12 PM, quan nexthop <quan.nexthop at gmail.com> wrote:
> Could you please share us your configuration ?
The basics of tmpfs are here: http://en.wikipedia.org/wiki/Tmpfs
Here's my config with most comments and white-space trimmed out:
________________________________________
worker_processes 4;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_http_version 1.0;
gzip_types text/plain text/xml text/css text/javascript
application/x-javascript;
gzip_buffers 8 32k;
gzip_comp_level 2;
#put nginx cache files into tmpfs ram disk that is backed by swap
proxy_cache_path /tmp/nginx_cache
levels=1:2
keys_zone=zone1:10m
inactive=7d
max_size=128m;
upstream backend {
ip_hash;
server 10.204.122.137;
server 10.224.122.138;
}
server {
listen 80;
server_name_in_redirect off;
#normalize all accept-encoding headers to just gzip or empty string
set $myae "";
if ($http_accept_encoding ~* gzip) {set $myae "gzip";}
#get rid of accept-encoding header for known-compressed file types
#we only want to store one version of these files in cache
if ($uri ~* \.(gif|jpg|jpeg|png|pdf|swf|flv|mp3|mp4|wmv)$) {set $myae "";}
access_log /var/log/nginx/localhost.access.log;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header Accept-Encoding $myae;
proxy_read_timeout 900;
proxy_redirect default;
proxy_cache zone1;
proxy_cache_valid 200 301 302 1m;
proxy_cache_key "$host$request_uri$myae";
}
}
More information about the nginx
mailing list