Skip to content

Instantly share code, notes, and snippets.

@nobuhiko
Last active December 14, 2015 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nobuhiko/5079787 to your computer and use it in GitHub Desktop.
Save nobuhiko/5079787 to your computer and use it in GitHub Desktop.
server {
listen 80;
server_name www.nob-log.info;
rewrite ^ http://nob-log.info$request_uri?;
}
charset utf-8;
# リバースプロキシの設定
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=czone:4m max_size=50m inactive=120m;
proxy_temp_path /var/tmp/nginx;
proxy_cache_key "$scheme://$host$request_uri";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffers 8 32k;
proxy_buffer_size 64k;
upstream backend {
ip_hash;
server 127.0.0.1:8080;
}
server {
listen 80;
server_name nob-log.info;
root /var/www/wordpress;
index index.php index.html index.htm;
access_log /var/log/nginx/wp.access.log main;
error_log /var/log/nginx/wp.error.log;
location /wp-admin { proxy_pass http://backend; }
location /wp-login.php { proxy_pass http://backend; }
location / {
if ($http_cookie ~* "comment_author_|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|Eudor
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;
}
}
server {
listen 8080;
server_name nob-log.info;
root /var/www/wordpress;
access_log /var/log/nginx/wp8080.access.log main;
error_log /var/log/nginx/wp8080.error.log;
client_max_body_size 36M;
# w3tc conf
include /var/www/wordpress/nginx.conf;
location / {
index index.php index.html index.htm;
# static files
if (-f $request_filename) {
#expires 14d;
break;
}
# request to index.php
if (!-e $request_filename) {
rewrite ^.+?($/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_max_temp_file_size 1M;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_index index.php;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ (\.ht|\.git|\.svn) {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment