Report this

What is the reason for this report?

How can I set policy for my DO Spaces to prevent hotlinking?

Posted on April 23, 2020

So I’m hosting image and video with DigitalOcean. But I want to block other websites use my video link on their website. Is using CORS config help? Because I tried but it doesn’t work.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya,

Just came across this answer and decided to write some general guidelines for anyone who comes across this in the future despite the old question.

In order to prevent other websites from directly linking to your videos, you’ll need to execute hotlink protection. However, applying CORS policy might not be sufficient since it’s primarily designed for controlling JavaScript’s AJAX and Fetch calls between different domains, not for blocking direct access.

You might want to consider other approaches such as using .htaccess file (if using Apache server) to prevent hotlinking or configure security settings in your CDN to block non-allowed referrers.

Note: All these methods will have to be applied server-side, so make sure to take necessary precautions not to disrupt your services. Always back up your data before making any major changes.

For further details, please check DigitalOcean’s tutorials on how to set up mod_rewrite for Apache or configuring Spaces CDN in official DigitalOcean docs.

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.