Mastering Nginx

(Ron) #1

Troubleshooting Techniques


[ 194 ]

This means that you need to disable SSL session reuse. You can do this by setting the


proxy_ssl_session_reuse directive to off.


Configuring advanced logging


Under normal circumstances, we want logging to be as minimal as possible. Usually


what's important is which URIs were called by which clients and when, and if there
was an error, to show the resulting error message. If we want to see more information,


that leads into a debug logging configuration.


Debug logging


To activate debug logging, the nginx binary needs to have been compiled with the
--with-debug configure flag. As this flag is not recommended for high performance


production systems, we may want to provide two separate nginx binaries for our


needs: one which we use in production, and one that has all the same configure
options, with the addition of --with-debug so that we may simply swap out the


binary at runtime in order to be able to debug.


Switching binaries at runtime

NGINX provides the capability to switch out binaries at runtime. After having
replaced the nginx binary with a different one, either because we're upgrading or we


would like to load a new NGINX which has different modules compiled in, we can


begin the procedure for replacing a running nginx binary:



  1. Send the running NGINX master process a USR2 signal, to tell it to start
    a new master process. It will rename its PID file to .oldbin (for example,
    /var/run/nginx.pid.oldbin):

    kill -USR2 cat /var/run/nginx.pid




There will now be two NGINX master processes running, each with its own
set of workers to handle incoming requests:
root 1149 0.0 0.2 20900 11768 ?? Is Fri03PM 0:00.13 nginx: master
process /usr/local/sbin/nginx
www 36660 0.0 0.2 20900 11992 ?? S 12:52PM 0:00.19 nginx: worker
process (nginx)
www 36661 0.0 0.2 20900 11992 ?? S 12:52PM 0:00.19 nginx: worker
process (nginx)
www 36662 0.0 0.2 20900 12032 ?? I 12:52PM 0:00.01 nginx: worker
process (nginx)
Free download pdf