stop image hijacking (anti-hotlinking) Lighttpd

Discussion in 'Site & Server Administration' started by jessepure, Jan 15, 2010.

  1. #1
    Hey everyone on forum,

    my code is:

     #### stop image hijacking (anti-hotlinking)
    
     
     $HTTP["referer"] !~ "^(http://website\.com|http://www\.website\.com)" {
      
      url.access-deny = ( ".jpg", ".jpeg", ".png", ".gif", ".bmp" )
    
    }
    Code (markup):
    but i have a problem, this code is blocking all direct images on the webpage (is not blocking normal show images, only direct!!), and i would need allow in one folder to direct linking..

    i just want please about your help how i have to do it?

    thank you all for answer
     
    jessepure, Jan 15, 2010 IP
  2. theapparatus

    theapparatus Peon

    Messages:
    2,925
    Likes Received:
    119
    Best Answers:
    0
    Trophy Points:
    0
    #2
    theapparatus, Jan 15, 2010 IP
  3. jessepure

    jessepure Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yup, thanks, this web i know very well, but this command does not work...
     
    jessepure, Jan 15, 2010 IP
  4. theapparatus

    theapparatus Peon

    Messages:
    2,925
    Likes Received:
    119
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ok, does that mean you tried the suggestion or what specifically?
     
    theapparatus, Jan 15, 2010 IP
  5. jessepure

    jessepure Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i tried add this command:

    but without change..

    default is set up to disable directlink on the whole website and i need enable direct linking for folder "thumbs".

    is it for image host. similarly like having big image hosts.
     
    jessepure, Jan 15, 2010 IP
  6. jessepure

    jessepure Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    ok, so i find out one thing, if i deleted
    $HTTP["referer"] !~ "^(http://website\.com|http://www\.website\.com)" {
    
    Code (markup):
    and added only
    $HTTP["url"] =~ "^/images/" {
    }  
    Code (markup):
    so content of whole website was enable with except folder "images"..but that folder images is blocking completly...does not work viewer of pictures..

    for example:

    all pictures i have in folder "images" which have to be blocking..

    direct link:
    http://www.website.com/images/8751395548712.jpg
    Code (markup):
    this is blocking, its good i want that.

    viewer link:
    http://www.website.com/viewer.php?img=8751395548712.jpg
    Code (markup):
    also this is blocking, its wrong for me, i need allow it.

    how to do it?

    thanks my mates so much.
     
    jessepure, Jan 16, 2010 IP
  7. jessepure

    jessepure Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    my code:

     #### stop image hijacking (anti-hotlinking)
    
        $HTTP["url"] =~ "^/images/" {
     
      url.access-deny = ( ".jpg", ".jpeg", ".png", ".gif", ".bmp" )
    
    }
    Code (markup):
     
    jessepure, Jan 16, 2010 IP
  8. tom210

    tom210 Peon

    Messages:
    87
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Its possible to do this in the lighttpd.conf however on my image host i use php to control hotlink protection and find this a much better solution as it allows you to be more flexible.
     
    tom210, Jan 16, 2010 IP
  9. jessepure

    jessepure Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    okay tom, have no any good solution for me? i will be very grateful :)
     
    jessepure, Jan 16, 2010 IP