0

I am running a Ubuntu virtual machine on Azure and on my landing page I wish to allow downloading a file I already uploaded to the server. For this reason I made a hyperlink in my index.html file using href tags, although aside from this I would like to navigate to it as well and as it turns out I am unable to accomplish either method. Specifically I obtain 404 Not Found in my browser after inputing my private IP address xx.xxx.xxx.xx followed by '/' and while trying out different paths to my file (located to /home/username/file.ext). Would anyone be more knowledgeable about whether or not files must be shared through enabling a setting as I do not wish to utilize alternative options such as Azure Files and SharePoint unless I need to.

1 Answer 1

2

For a file to be accessible for download over http/https it must be stored in location on the file system that has been designated as publicly accessible by the server administrator.

Your personal home directory /home/username/ is neither publicly accessible and should never be made so by an administrator.

Either place your file in (a sub directory of) the default DocumentRoot of the web server (often that will be /var/www/html) or whatever other location your website uses.

When you have many users that you want to allow a personal website and download area, you can for example enable and use Apache's Userdir . By convention that designates every /home/<login>/public_html/ sub directory (although you can adjust to the public_html subdirectory name) as publicly accessible and the content there will become available over http[s]://www.example.com/~login/

When the file has been stored in the correct location on your system and the download still fails, check the web server (error) logs for the cause. Incorrect file system permissions for example could also still block the download.

1
  • Would a symlink work in the place of my file in the DocumentRoot of the web server? Otherwise I would have to use 'cp' to place it there I believe. What system permissions do you allude to, I would like to learn more on this subject.
    – aitía
    Jul 9, 2022 at 15:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .