Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created October 5, 2011 05:26
Show Gist options
  • Save ukstudio/1263712 to your computer and use it in GitHub Desktop.
Save ukstudio/1263712 to your computer and use it in GitHub Desktop.
user nginx nginx;
worker_processes 1;
error_log /var/log/nginx/error_log info;
events {
worker_connections 1024;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main
'$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';
client_header_timeout 10m;
client_body_timeout 10m;
send_timeout 10m;
connection_pool_size 256;
client_header_buffer_size 1k;
large_client_header_buffers 4 2k;
request_pool_size 4k;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
output_buffers 1 32k;
postpone_output 1460;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 75 20;
ignore_invalid_headers on;
index index.php index.html index.htm;
proxy_cache_path /var/www/nginx_cache levels=1:2 keys_zone=czone:4m max_size=50m inactive=120m;
proxy_temp_path /var/www/nginx_tmp;
server {
listen 8001;
server_name _;
access_log /var/log/nginx/fastcgi.access_log main;
error_log /var/log/nginx/fastcgi.error_log info;
root /var/www/localhost/htdocs/wordpress;
location ~ .*.php$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:65532;
fastcgi_index index.php;
}
if (-f $request_filename) {
#expires 30d;
break;
}
if ( !-e $request_filename) {
rewrite ^.+?(/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^.* /index.php last;
}
}
upstream backend {
ip_hash;
server 127.0.0.1:8001;
}
server {
listen 80;
server_name ukstudio.jp;
access_log /var/log/nginx/ukstudio.access_log main;
error_log /var/log/nginx/ukstudio.error_log info;
location ~ /*\.(htm|html|jpg|JPG|jpeg|gif|GIF|png|PNG|swf|SWF|css|CSS|js|JS){
root /var/www/localhost/htdocs/wordpress;
index index.html;
break;
}
location /wp-admin { proxy_pass http://backend; }
location /wp-login.php { proxy_pass http://backend; }
set $do_not_cache 0;
location / {
if ($http_cookie ~* "comment_aurhor_|wordpress_($!test_cookie)|wp-postpass_") {
set $do_not_cache 1;
}
if ($http_user_agent ~* ¡È2.0\ 2MMP|240¡ß320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800¡í) {
set $do_not_cache 1;
}
proxy_no_cache $do_not_cache;
proxy_cache_bypass $do_not_cache;
proxy_pass http://backend;
proxy_cache czone;
proxy_cache_key $scheme$proxy_host$uri$is_args$args;
proxy_cache_valid 200 10m;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment