hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Hotlink protection with nginx?
Reply

Hosting Security and Technology Configuring and optimizing web hosting servers and operating systems, developing administration scripts, building servers, protecting against hackers, and general security (SSL certificates, etc.)
Forum Jump

Hotlink protection with nginx?

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 07-24-2008, 06:38 AM
digitalpioneer digitalpioneer is offline
Temporarily Suspended
 
Join Date: Feb 2007
Posts: 184
Question

Hotlink protection with nginx?


Hey, does anyone on this forum know how to do a referral check to prevent hot linking to files that are on a nginx server? There is this regex code you use but I don't know how to put it together. Anyone have a clue how to do it on nginx using their rewrite module?

Reply With Quote


Sponsored Links
  #2  
Old 07-24-2008, 06:46 AM
zuborg zuborg is offline
WHT Addict
 
Join Date: Jun 2008
Location: Ukraine
Posts: 141
location ~ \.(jpg|png|gif)$ {
valid_referers server_names blocked none frienddomain.com *.frienddomain.com ;
if ($invalid_referer) {
return 403;
}
}

__________________
Know all about your site performance:
http://Site-Perf.com/

Reply With Quote
  #3  
Old 07-24-2008, 06:52 AM
digitalpioneer digitalpioneer is offline
Temporarily Suspended
 
Join Date: Feb 2007
Posts: 184
does that allow blank referrals? i'd like it to let blank ones pass

Reply With Quote
Sponsored Links
  #4  
Old 07-24-2008, 06:59 AM
zuborg zuborg is offline
WHT Addict
 
Join Date: Jun 2008
Location: Ukraine
Posts: 141
yes, 'none' keyword allows blank refs

__________________
Know all about your site performance:
http://Site-Perf.com/

Reply With Quote
  #5  
Old 07-24-2008, 07:28 AM
digitalpioneer digitalpioneer is offline
Temporarily Suspended
 
Join Date: Feb 2007
Posts: 184
well it does not work... it is blocking everything and yes i changed frienddomain.com to my site (which it should accept referrals from)

Reply With Quote
  #6  
Old 07-24-2008, 07:56 AM
zuborg zuborg is offline
WHT Addict
 
Join Date: Jun 2008
Location: Ukraine
Posts: 141
You don't need to change frienddomain.com to you site - 'server_names' keyword do it for you.
Just skip other domains and leave 'server_names none blocked' keywords.

About 'blocking everything': comment 'return 403;' by '#' - if it will continue blocking - the issue is definitely not in hotlink protection. I can not imagine that config I show will block everithing. Are you sure you are using proper referer in your requests ? How about empty referer ?

__________________
Know all about your site performance:
http://Site-Perf.com/

Reply With Quote
  #7  
Old 07-24-2008, 05:03 PM
digitalpioneer digitalpioneer is offline
Temporarily Suspended
 
Join Date: Feb 2007
Posts: 184
Yeah it still blocks when i comment out return 403. Also, it does not give me 403 errors but 404 errors instead. why is that? and yes i am using a proper referrer

Reply With Quote
  #8  
Old 07-24-2008, 06:33 PM
digitalpioneer digitalpioneer is offline
Temporarily Suspended
 
Join Date: Feb 2007
Posts: 184
I am using the debian nginx package (0.5.35-2 lenny) and i have added the code you have given me to /etc/nginx/sites-available/<my_site> in the server { ... } area.

Reply With Quote
  #9  
Old 07-25-2008, 04:04 AM
digitalpioneer digitalpioneer is offline
Temporarily Suspended
 
Join Date: Feb 2007
Posts: 184
anyone have a clue?......... =(

Reply With Quote
  #10  
Old 07-26-2008, 01:18 AM
digitalpioneer digitalpioneer is offline
Temporarily Suspended
 
Join Date: Feb 2007
Posts: 184
wow out of so many so called sys admins and hosts on here none have a clue. says a lot

Reply With Quote
  #11  
Old 07-26-2008, 06:47 PM
digitalpioneer digitalpioneer is offline
Temporarily Suspended
 
Join Date: Feb 2007
Posts: 184
maybe rewrite module is not enabled? hello anyone? how do i enable it?

Reply With Quote
  #12  
Old 07-28-2008, 05:42 AM
zuborg zuborg is offline
WHT Addict
 
Join Date: Jun 2008
Location: Ukraine
Posts: 141
Quote:
Originally Posted by digitalpioneer View Post
Yeah it still blocks when i comment out return 403. Also, it does not give me 403 errors but 404 errors instead. why is that? and yes i am using a proper referrer
404 error means 'Not Found'
Look at error logs.

__________________
Know all about your site performance:
http://Site-Perf.com/

Reply With Quote
  #13  
Old 07-28-2008, 12:45 PM
funkywizard funkywizard is offline
unghhh... Baaandwidth....
 
Join Date: Jan 2005
Posts: 7,811
why are you using such an old version of nginx anyway?

__________________
IOFLOOD.com -- We Love Servers
Are you a Minecraft host?
Ask about our new E3-1240v2 servers.
Email (sales [at] ioflood . com) or skype "funkywizard" for details.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
nginx Version 1.4.0 Supports SPDY Protocol Web Hosting News 2013-04-29 15:08:14
Open Source Server NGINX Makes LeaseWeb its Preferred Infrastructure Partner Web Hosting News 2012-03-21 18:52:57
nginx Continues Market Share Momentum in Netcraft February Web Server Survey Web Hosting News 2012-02-09 17:29:14
Web Server NGINX Partners With CDN Firm Jet-Stream Web Hosting News 2011-11-21 19:21:42
Open Source Web Server NGINX Receives $3 Million Investment Web Hosting News 2011-10-11 15:24:24


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?