-1

Lets get straight to the point.

I am putting my old VHS/DVD contents on my hardDrive. Which is located in /mnt/d/Movies, i am using windows and have WSL (windows subsystem linux). The WSL is where the webserver is hosted from as i would like to serve all this movies via my LAN to anyone wanting to watch them (LAN ONLY). Made a dynamic page to select the movie and load it.

movieDir Location: /mnt/d/Movies/Speed.2.Cruise.Control-1997/Speed.2.Cruise.Control-1997.mkv

When i try the following

$lanSite->movieDir = 'https://localhost/mnt/d/Movies/' <--- 100% certain that its trying to read a folder that does not exists within the "localhost"

<video>
  <source  style="height:600px; width:480px;" src="<?= $lanSite->movieDir . DIRECTORY_SEPARATOR . $movieName . "-" . $movieYear . $movieFile; ?>" type="video/mp4">
</video>

NOTE: video files are being encoded into either mkv / mp4 depending on which one comes out the best for storing purposes.

URL USED: /mnt/d/Movies/Speed 2 Cruise Control-1997/Speed.2.Cruise.Control-1997.mkv Tried the above which does not seem to load anything. When i try to check if the Dir and File exists they appear to exist but not load within the localhost page.

then i tried using apache .htaccess to redirect the /mnt/d/Movies folder .htaccess: RewriteRule ^movie-file/(.*)$ movie_details.php?movie=$1

The above did not work, actually i think i ended up at the same place with a different approach.

I then realized that its outside of the rootDir, done some googling. The end result was me resetting my WSL due to a dir mixup.

Anyone perhaps know what could be the issue, if i load a file within the server no problem, although the server has 512GB storage and the movies i have encoded so far are at 650GB, externally using them from the drive itself is my only option.

Random Combos i tried:

https://localhost/mnt/d/Movies/Speed 2 Cruise Control-1997/Speed.2.Cruise.Control-1997.mkv
../../mnt/d/Movies/Speed 2 Cruise Control-1997/Speed.2.Cruise.Control-1997.mkv
//mnt/d/Movies/Speed 2 Cruise Control-1997/Speed.2.Cruise.Control-1997.mkv
D:\Movies\Speed 2 Cruise Control-1997\Speed.2.Cruise.Control-1997.mkv
file:///D:\Movies\Speed 2 Cruise Control-1997\Speed.2.Cruise.Control-1997.mkv

All combinations i have tried, failed epically. Yes, i have tried .mp4 and it comes with the same result --> folder Found --> file Found --> unable to see player or play

  • Does this answer your question? [How can I create a link to a local file on a locally-run web page?](https://stackoverflow.com/questions/18246053/how-can-i-create-a-link-to-a-local-file-on-a-locally-run-web-page) – tacoshy Aug 24 '21 at 12:25
  • No its does not, i would like to run it within the web page. using ` – OpenSourceAdvocate Aug 24 '21 at 12:28
  • 1
    First at all you need an abiltiy to access your local hard drive. That link explains how you do it. Next (which is most-likely) you get firewall, read-permission errors. Its "impossible" for an HTML file to simply access an external hard-drive. Thats the whole reason why you have web-servers in the first place. – tacoshy Aug 24 '21 at 12:30
  • 2
    Why do you think files outside of your document root can be accessed through the webserver? That would allow to download your private files too, like private keys. Move the file into your document root. – Daniel W. Aug 24 '21 at 12:30
  • @DanielW. i do not think that, this is the first time, i never ever give access to any folder outside of the rootDir for the exact reason you gave me... i could `.../etc/passwd`, although this is on my LAN only available to LAN users and i though no point in security as i built it to not ever reach the WAN. I thought it might not be possible but i needed to see if SO had a solution better than making the external drive the rootDir – OpenSourceAdvocate Aug 24 '21 at 12:35
  • @tacoshy i have access to the drive, i gave chown www-data to access all the folders and files. No permission issue, no firewall issue as its behind and will not reach the outside as for security, does not matter as this server will not reach WAN my dns will kill the traffic. – OpenSourceAdvocate Aug 24 '21 at 12:36
  • 1
    you got access to your drive but not a HTML file itself that is run on another device. If an HTML file (with very limited exeptions as choosing files for upload) would be allowed to access external drives then this would cause the biggest security issues. So unless the drive will be part of the webserver itself, assume it to be impossible. – tacoshy Aug 24 '21 at 12:39
  • @tacoshy Yes sir, its basically the issue where the back-end can read the file but the html simply would not load as its not in the root dir but in `/mnt/d/`. So its impossible lol first time for everything i guess, it will 100% work if the moviesDir was within the `/var/www/html` folder. I guess the loop whole would be --> setup OMV --> setup local webserver on OMV that would give the back-end and the HTML the appropriate permission to load the file in the browser – OpenSourceAdvocate Aug 24 '21 at 12:45
  • I guess you have a few misconception of how a websever, a browser and a HTML file work. Also confuse to throw front--end and back-end in when we talk about server adminstration and function. It has nothing to do with back-end or front-end. Simply put: Your Webserver wont eb able to just connect to an external harddrive. As such a HTML file that is downloaded by your browser will never be able to access it as the server the browser trying to accesss it can't connect to the external drive. – tacoshy Aug 24 '21 at 12:49
  • 1
    You could make your webserver follow symlinks and simply symlink your mounted drive into the document root. Search for "follow symlinks " on your favorite search engine. – Daniel W. Aug 24 '21 at 13:19
  • @DanielW. i gave the Windows shortcut folder a try and that did not work, although i forgot to test the symlinks. Will give that a go shortly..... duckduckgo / google (if im desperate) :) – OpenSourceAdvocate Aug 24 '21 at 13:21
  • [Apache on Windows](https://stackoverflow.com/questions/3034860/apache-virtual-host-in-windows-how-do-i-deal-with-symbolic-links) or [Apache on Windows 7](https://superuser.com/questions/235944/using-symbolic-link-directories-with-apache-php-and-windows-7) might help =) – Daniel W. Aug 24 '21 at 16:08

1 Answers1

0

"You could make your webserver follow symlinks and simply symlink your mounted drive into the document root. Search for "follow symlinks " on your favorite search engine" - @DanielW.

Solution

created a movies folder within the root webserver directory.

mkdir /var/www/html/movies/

Then i used the mount for Linux as im using WSL

mount --bind --verbose /mnt/d/Movies /var/www/html/movies

Note: this will work, although you might need to create a script so it can be mounted on-Boot

quite littrally did a search for "follow symlinks <yourwebserver> <operatingsystem>" and found the solution within a few links

when accessing https://localhost/movies/movieFolder/fileName.mp4 it now loads from /mnt/d/Movies instead of having the web rootDir in the Movies folder.

Thanks @DanielW. @tachoshy for your assistance :)