0

PROBLEM:

My website has denied access to files outside of /var/www/html/ directory.

DESCRIPTION:

My website is running from /var/www/html/ directory on a VPS.
I'd like my website to access some important files from /var/www/safe/ directory (like it does on my local computer). Unfortunately access to files on this safe directory is denied and systematically restricted even when I change permissions.

QUESTIONS:

  • Is this the correct way to protect and access some important files?
  • Is there a better solution to protect such files?
9
  • There are many possible ways to protect important files. The method depends upon how you intend to use the files, and the types of attack you intend to protect them from.
    – user535733
    Jan 12, 2020 at 20:14
  • What may be the problem or what is the correct way to make my solution working well?
    – dryhay
    Jan 12, 2020 at 20:19
  • What are the contents of the "safe" directory. Does it contain data (database etc.) files used by scripts under "html" directory or does it contain the html pages and/or scripts themselves that need to be accessed by the web server itself?
    – FedKad
    Jan 12, 2020 at 20:23
  • @FedonKadifeli This directory contains scripts with fragile data and the website needs access to display it somewhere.
    – dryhay
    Jan 12, 2020 at 20:55
  • Your problem description is not clear. What do you mean with "the website": Is it a collection of PHP scripts or something else coded in another language? Data access will depend heavily on how your "web site" is coded and your "fragile data" is stored: Is it in MySQL or any other kind of database system?
    – FedKad
    Jan 13, 2020 at 9:22

1 Answer 1

0

That depends highly on what you are trying to do. For example, the default user running the Apache Web Server is www-data. If you want a script being run by Apache Server to read-access a file that it does not have read access, you can use the following command:

setfacl -m u:www-data:r /path/to/file

To give write access the another file for example use:

setfacl -m u:www-data:w /path/to/another/file

See https://manpages.ubuntu.com/manpages/en/man1/setfacl.1.html

You must log in to answer this question.

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