How to enable hot linking in nginx?


#1

Hey guys I have to disable hot linking in my server. How can I do this on nginx?


#2

How did You disable hotlinking? Just reverse it :wink:

It isn’t enabled by default on nginx.


#3

Sorry I made a mistake I want to disable it.:relaxed::open_mouth:


#4

Do You host content in a single directory?

You can use

Location somedirectory {
  Deny All;
  Allow from your_host_name;
}

Warning: Syntax is written from the top of my head and is untested, please do Your due diligence before uploading.


#5

Check server block.

cd /etc/nginx/sites-available/ && vdir
nano my-site

#6

Hey bro I added following code in server block and sever test is also successful but I have two new question.

  1. How can I check is this working?
  2. As you know! we also have a cdn.example.com domain. So, do we need to add cdn domain in conf?
location ~ .(gif|png|jpeg|jpg|svg)$ {
     valid_referers none blocked ~.google. ~.bing. ~.yahoo. yourdomain.com *.yourdomain.com;
     if ($invalid_referer) {
        return   403;
    }
}

#7

BunnyCDN has inbuilt features for the same. You can use.


#8

Ok how can check hot linking is working?


#9

Here you go http://altlab.com/hotlinkchecker.php


#11

Hey brow I speed up my website as much as I possible. I also found best tutorial but I am unable to follow those steps.

By the way Please analyse my website speed and give me review about how my website load?

Second thing I have decided to go with BunnyCDN. - ya it is true if our server and cdn is belongs to from same location. This means not much beneficial for speed. But we don’t have an idea from which location google is crawling our website to analyse speed. If we enabled CDN we don’t need to think about google and page speed.

The last thing about that I am thinking a lot…

Bro my images load from cdn.domain.com will it safe for SEO?
Screenshot_4

I am asking this question because many blogs that are using cdn their image loads by main domain.

The nearest example is of your blog. You are using BunnyCDN but I haven’t seen cdn.gulshankumar.net with image. I hope you have understood about what was I trying to say.