Chapter 8
[ 203 ]
}
location /images {
access_log logs/example.com-images_access.log imagelog;
}
location /auth {
auth_basic "authorized area";
auth_basic_user_file conf/htpasswd;
deny all;
access_log logs/example.com-auth_access.log authlog;
}
}
}
In the preceding example, there is an access_log declaration for each location, as
well as a different log_format for each access_log declaration. We can determine
which requests made it to each location depending on the entries found in the
corresponding accesslog. If there are no entries in the example.com-images
access.log file, for example, then we know that no requests reached the /images
location. We can compare the contents of the various log files to see if the variables
are being set to the proper values. For example, if the $imagefile and $image
type variables are empty, the corresponding placeholders in the imagelog format
access_log will be empty.
Common configuration errors
The next step in troubleshooting a problem is to take a look at the configuration,
to see if it actually achieves the goal you are trying to accomplish. NGINX
configurations have been floating around the Internet for a number of years.
Often, they were designed for an older version of NGINX, and to solve a
specific problem. Unfortunately, these configurations are copied without really
understanding the problem they were designed to solve. There is sometimes a
better way to solve the same problem, using a newer configuration.