nginxのconfですが、includeとか大量にしていると、うっかり上書きされててハマったことないですか?
自分は最近ドハマりして、イラッとして、confをdumpできるようにならなかと調べてみました。
で、最新のnginxのソースcloneして読んでたらもうあるじゃんと思ったのですが、 自分のマシンに入ってたnginx(1.6.2)にないので、調べてみたら20150/05/15に入った変更だったのですね。。。
で、1.9.3を手元でコンパイルして試してみました。
nginxのコマンドオプションに-T
が追加されて、これを使うと、confファイルが吐出されるようになります。
# /foo/bar/nginx-1.9.3/objs/nginx -h nginx version: nginx/1.9.3 Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives] Options: -?,-h : this help -v : show version and exit -V : show version and configure options then exit -t : test configuration and exit -T : test configuration, dump it and exit -q : suppress non-error messages during configuration testing -s signal : send signal to a master process: stop, quit, reopen, reload -p prefix : set prefix path (default: /usr/local/nginx/) -c filename : set configuration file (default: conf/nginx.conf) -g directives : set global directives out of configuration file
dumpされる内容はこんな感じ。
# configuration file /nginx.conf: include ../hoge.conf; worker_processes 8; events { accept_mutex off; worker_connections 8192; use epoll; } http { server_names_hash_bucket_size 64; upstream hoge { server 127.0.0.1:3000; } server { include ../hoge1.conf; listen 80; client_max_body_size 500M; location / { proxy_pass http://hoge; } keepalive_timeout 5; keepalive_requests 5; } } # configuration file ../hoge.conf: pid /var/run/nginx.pid; user nginx; worker_rlimit_nofile 65535; # configuration file ../hoge1.conf: include ../mime.types; default_type application/octet-stream; gzip on; # configuration file ../mime.types: types { text/html html htm shtml; text/css css; text/xml xml; image/gif gif; image/jpeg jpeg jpg; application/x-javascript js; application/atom+xml atom; application/rss+xml rss; }
とりあえずconfファイルを出すだけなのか。。。
ネストされている、confも全部だしてくれます。
includeされたファイルを反映させて、最終的に適用される値が出てくるわけではないので、もう一工夫いるなあ。