nginxのエラーログが出力されない時は。。。

参考にしたのは以下の本。
エラー画面が出ているのに全然エラーログが吐き出されなかったのですが、この本に助けられました。
nginx.conf
kusanagiコマンドでwordpress環境を構築しました。
以下がnginx.conf
rootは /etc/nginx/nginx.confで設定しています。
## default HTTP
server {
listen 80;
server_name default_server;
access_log /home/kusanagi/wordpress/log/nginx/access.log main;
error_log /home/kusanagi/wordpress/log/nginx/error.log warn;
index index.php index.html index.htm;
charset UTF-8;
client_max_body_size 16M;
location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ /\.ht {
deny all;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~* /\.well-known {
allow all;
}
# 以下ネストが変になってます。
location ~* /\. {
deny all;
}
#include templates.d/multisite.conf;
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
location ~* \.(jpg|jpeg|gif|png|css|js|swf|ico|pdf|svg|eot|ttf|woff)$ {
expires 60d;
access_log off;
}
location ~* /blog/wp-login\.php|/wp-admin/((?!(admin-ajax\.php|images/)).)*$ {
satisfy any;
allow 0.0.0.0/0;
allow 127.0.0.1;
deny all;
auth_basic "basic authentication";
auth_basic_user_file "/home/kusanagi/.htpasswd";
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffers 256 128k;
fastcgi_buffer_size 128k;
fastcgi_intercept_errors on;
fastcgi_read_timeout 120s;
#include naxsi.d/wordpress/*.conf;
}
#include naxsi.d/wordpress/*.conf;
}
location ~ [^/]\.(php|html)$ {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffers 256 128k;
fastcgi_buffer_size 128k;
fastcgi_intercept_errors on;
fastcgi_read_timeout 120s;
set $do_not_cache 1; ## page cache
set $device "pc";
if ($request_method = POST) {
set $do_not_cache 1;
}
if ($query_string != "") {
set $do_not_cache 1;
}
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $do_not_cache 1;
}
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $do_not_cache 1;
}
if ($http_user_agent ~* " Android |\(iPad|Android; Tablet; .+Firefox") {
set $device "tablet";
}
if ($http_user_agent ~* " Android .+ Mobile |\(iPhone|\(iPod|IEMobile|Android; Mobile; .+Firefox|Windows Phone") {
set $device "smart";
}
fastcgi_cache wpcache;
fastcgi_cache_key "$device:$request_method:$scheme://$host$request_uri";
fastcgi_cache_valid 200 10m;
fastcgi_no_cache $do_not_cache;
fastcgi_cache_bypass $do_not_cache;
add_header X-F-Cache $upstream_cache_status;
add_header X-Signature KUSANAGI;
#include naxsi.d/wordpress/*.conf;
}
}
デフォルトの http.conf で一旦試してます。
現象
wordpressをサブディレクトリにして、特定のリンクを踏んだら、別のディレクトリを読み込むような設定をやっている最中突然エラーログが出なくなりました。
というより、そのリンクを踏んだ時だけエラーが出ずに詰んでました。
解決策
エラーの log levelが原因でした。
## default HTTP
server {
listen 80;
server_name default_server;
access_log /home/kusanagi/wordpress/log/nginx/access.log main;
error_log /home/kusanagi/wordpress/log/nginx/error.log debug;
index index.php index.html index.htm;
charset UTF-8;
client_max_body_size 16M;
・
・
・
log level を一番下の debugにしてみたら noticeが表示された。
これでやっと前に進めそうです。
最後に
ログの出力先に全く問題がないときにはログレベルを疑いましょう(超反省)。
ポケットリファレンスは小さくてマジで便利ですね。おすすめです。