nifty config tip for nginx and rails apps
If you’ve got a rails site running on nginx, you’ve more than likely seen your nginx access logs & production log polluted with calls to favicon.ico and phpinfo.php and all sorts of other stuff. Here’s a quick and easy way for nginx to drop all those requests: In the folder that houses the nginx.conf file, create a drop.conf file with the following:
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ \.(php|asp|cfm|jsp) { access_log off; log_not_found off; return 204; }
location ~ /\. { access_log off; log_not_found off; deny all; }Then at the end of your server declaration block:
server {
....
include drop.conf;
}This will quit the logging of favicon.ico along with robots.txt. It will drop all requests for languages not used in you app and will deny access to any dot file in your apps folders Thanks to this site for giving me some great examples: https://calomel.org/nginx.html