Advertisement
phpface

Nginx - Prevent other domains from accessing video files

Aug 26th, 2022 (edited)
2,728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 1.30 KB | None | 0 0
  1. ##
  2. # You should look at the following URL's in order to grasp a solid understanding
  3. # of Nginx configuration files in order to fully unleash the power of Nginx.
  4. # https://www.nginx.com/resources/wiki/start/
  5. # https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
  6. # https://wiki.debian.org/Nginx/DirectoryStructure
  7. #
  8. # In most cases, administrators will remove this file from sites-enabled/ and
  9. # leave it as reference inside of sites-available where it will continue to be
  10. # updated by the nginx packaging team.
  11. #
  12. # This file will automatically load configuration files provided by other
  13. # applications, such as Drupal or Wordpress. These applications will be made
  14. # available underneath a path with that package name, such as /drupal8.
  15. #
  16. # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
  17. ##
  18.  
  19. # Default server configuration
  20. #
  21. server {
  22.     listen 80 default_server;
  23.     listen [::]:80 default_server;
  24.  
  25.     # etc .......
  26.     # etc .......
  27.     # etc .......
  28.     # etc .......
  29.  
  30.     # Prevent other domains from accessing your video files
  31.  
  32.     location ~* \.(mp4|m3u8|key|webp|mov)$ {
  33.  
  34.         # Define your domain name
  35.  
  36.         valid_referers none blocked server_names https://your-domain.com*;
  37.  
  38.         if ( $invalid_referer = "" ) {
  39.             return 403;
  40.         }
  41.     }
  42.        
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement