Skip to content

Instantly share code, notes, and snippets.

@timbuchwaldt
Created July 9, 2009 11:25
Show Gist options
  • Save timbuchwaldt/143586 to your computer and use it in GitHub Desktop.
Save timbuchwaldt/143586 to your computer and use it in GitHub Desktop.
user www www;
worker_processes 4;
worker_rlimit_nofile 20480;
error_log logs/error.log;
events
{
use epoll;
worker_connections 81920;
}
http
{
keepalive_timeout 1800;
ncache_max_size 24;
proxy_buffering off;
ncache_dir /data1/ngx_cache/ 128 64;
ncache_dir /data2/ngx_cache/ 128 64;
ncache_dir /data3/ngx_cache/ 128 64;
ncache_dir /data4/ngx_cache/ 128 64;
ncache_ignore_client_no_cache on;
upstream backend
{
server 78.47.93.49;
}
sendfile on;
send_timeout 90;
client_header_timeout 120;
tcp_nodelay on;
log_format main '$proxy_add_x_forwarded_for - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" $remote_addr';
include "mime.types";
server
{
server_name .piraten.21studios.de;
listen piraten.21studios.de:8080;
set $xvia "piraten.21studios.de";
set $proxy_add_agent "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; NginxCache)";
#access_log logs/blog.sina.com.cn-access_log main;
location /
{
if ($request_method ~ "PURGE")
{
rewrite (.*) /PURGE$1 last;
}
if ($request_uri = /)
{
rewrite ^/$ /lm/index.html last;
}
ncache_http_cache;
error_page 404 = /fetch$request_uri;
add_header Sina-Cache $xvia;
}
location /ncache_state
{
ncache_state;
}
location /fetch
{
internal;
proxy_pass http://backend;
add_header Sina-Cache $xvia;
proxy_hide_header User-Agent;
proxy_set_header User-Agent $proxy_add_agent;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
sub_filter '</head>' '</head><em> Cached by 21Studios.de</em>';
sub_filter_once on;
}
location /PURGE/
{
#access_log logs/purge.blog.sina.com.cn-access_log main;
#internal;
allow all;
#deny all;
ncache_purge;
}
location /nginx_status {
# copied from http://blog.kovyrin.net/2006/04/29/monitoring-nginx-with-rrdtool/
stub_status on;
access_log off;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment