1. Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as:

    All that and more! Registration is quick, simple and absolutely free. Join our community today!

Tutorial How to protect against image hot linking in Nginx Web Server

Discussion in 'Linux Distributions' started by Draft, Jan 23, 2014.

  1. Draft

    Draft Administrator Staff Member Administrator

    I had two options: 1. Configure Nginx to refuse to serve images to the thief; 2. Serve a special image that tells the whole universe that the owner of the website they are viewing is a parasite. Because majority of the articles published on this site tend to be image-heavy, serving a special image that delivers a message will have the same impact on my bandwidth, so I chose option number 1.

    In the site’s config file, I put this in the server{} context:

    That works. Every image hotlinked from this website will just show the “alt” text on the thief’s website, with a lot of white space where the image is supposed to be. Any attempt to view the image will return a “403 Forbidden” error page. I’m pretty sure that’s the best configuration to use, but if you know of a better manner of setting it up, please post a comment.

    The other option, which I did not use, is this:


    That rewrite line can be tricky to pull off, so be careful if you want to consider using it. If the message and the color combination seems a bit harsh, that tells you how I feel about the offender. For now, a “403 Forbidden” will do.
     
  2. hmmmmmm. bm ko muna
    repa ts s tut mo
     
Tags / Keywords: