Skip to content

Moving videos directory and securing files from direct access to the video source file

YouPHPTube edited this page Nov 28, 2017 · 21 revisions

This tutorial shows you how to enable Apache XSendFile to prevent your videos from being accessed by external or unauthorized users. It will also help you set up the symbolic link to allow you to move your videos to another location

Need help to configure it?

Get 1 hour support on our Services Site, we will do it for you

DIY

What we use for that:

  1. Ubunut 16
  2. Apache XSendFile
  3. SecureVideosDirectory Plugin

What will you need

  1. Root Access to the server
  2. Admin user for YouPHPTube

Enable SecureVideosDirectory

This is necessary for secure files and configuration assistant

Install apache xsendfile

sudo apt-get install libapache2-mod-xsendfile && sudo a2enmod xsendfile

Configure your apache XSendFile

sudo nano /etc/apache2/apache2.conf

<Directory /var/www/YouPHPTube/>
    Options Indexes FollowSymLinks
    XSendFile on
    XSendFilePath /var/www/YouPHPTube/
    AllowOverride All
    Require all granted
    Order Allow,Deny
    Allow from All
</Directory>

Uncomment your .htaccess file

sudo nano /var/www/YouPHPTube/.htaccess

<IfModule mod_xsendfile.c>
    RewriteRule    ^videos/([A-Za-z0-9-_.]+)$ view/xsendfile.php?file=$1    [NC,L]
</IfModule>

Move your videos directory

sudo mv /home/daniel/Dropbox/htdocs/YouPHPTube/videos /home/daniel/Documentos/videos

Must create a symbolic link

sudo ln -s /home/daniel/Documentos/videos /home/daniel/Dropbox/htdocs/YouPHPTube/videos

Test it on demo site

There is a Video, it is not public. The video source file is https://demo.youphptube.com/videos/_YPTuniqid_599cee25994a94.99095552.mp4, you will only be able to see the source file if you are logged in on demo site.

Clone this wiki locally