rasensio
12/28/2016 - 11:46 AM

nginx-images-lockdown

		location / {
        # apply rate limiting
        limit_req zone=images burst=15;
        access_log  /var/log/nginx/your-access-logs.log keyval;

        # prevent hotlink cheap motherfuckers
        if ($http_referer ~* (drupal|ejercicios|fceateachers|cool|goodsgram|iconnect|hdpix|imag|mapsology|alamaula|china|picbook|php|canrole|carapics|clipart|baidu|about|goplaceit|vivados|doomos|bienesonline) ) {
                rewrite (.*) http://www.mycompany.com/img/logo-com-500.png redirect;
        }

				# block all these user agents #1 bloodsuckers
        if ($http_user_agent ~* (pampa|curl|drupal|hubspot|photon|livelap|sightup|google|baidu|perl|adsbot|yahoo|msnbot|python|ahrefs|wget|majestic|bing|superfish|paperlibot|visionutils) ) {
            return 403;
        }

				# prevent null user agent you sneaky rat
        if ($http_user_agent = "") {
            return 403;
        }

        #your aws bucket, die cloudfront!
        proxy_pass http://s3.amazonaws.com:80;
        expires 2M;
        add_header Pragma public;
        add_header Cache-Control "public";
		}