Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
25% Recurring Discount on NVMe VPS
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

nginx frontend proxy for apache and hotlink protection

ndelaespadandelaespada Member, Host Rep

I have a server running nginx as frontend proxy for apache and i'm trying to configure hotlink protection, the server has mostly mp3s and hotlink is killing bw, I have the following in the site config file:

      location ~* (\.bin|\.zip|\.mp4|\.mp3|\.jpg|\.png)$ {
      valid_referers blocked mysite.com www.mysite.com *.google.com *.bing.com *.yahoo.com;
      if ($invalid_referer)  {
      return 405;
      }

but for some reason the only extension getting blocked is .bin, everything else loads without restriction.

Can anyone shed some light? I've tried several suggestions I've found on the net without any luck

Comments

  • I have never bothered much, if any, with hotlink protection, but I can tell you two things right off the bat:
    1) never ever blindly copy/paste configurations

    2) don't use "if" statements with Nginx; that is a really old, outdated, and bad way of doing things.

    That being said, check out http://www.kbeezie.com - he knows his way around Nginx, he works with us, and his is a Nginx contributor.

  • sleddogsleddog Member
    edited November 2013

    said: the only extension getting blocked is .bin

    Perhaps other extensions are being handled by other, prior, directives.

  • budi1413budi1413 Member
    edited November 2013

    You can simplify it like this:

    location ~ \.(bin|zip|mp4|mp3|jpg|png)$ {
     ...
    }
    
  • ndelaespadandelaespada Member, Host Rep

    @sleddog said:

    Thank was exactly it! thanks!

    @budi1413 said:
    You can simplify it like this:

    Thanks, just applied that change,

Sign In or Register to comment.