I need to make my users' home directories available to them over the web. I have LDAP authentication in place so only valid users can access the home directories but currently a valid user can access any given home directory. I want to jail users to their own home directory. Is this possible with Apache?

  • Just to be clear, when say jail, "/~joebob" is only accessible to the user joebob, but joebob could not go to "/~thomvu"? – sysadmin1138 Jun 13 '12 at 14:33
  • Correct. I'm aware of the Apache variable REMOTE_USER but I'm not sure how, if I'm even able to, use that to keep users in their own directory. – Tristan Hall Jun 13 '12 at 14:39

You could use vhost-alias, to deliver the user in their directory after authentication, and they won't be able to go into anyones else's directory.

  • Thank you. Is it possible to use %{remote_user} with this setup? – Tristan Hall Jun 14 '12 at 14:06
  • I don't have the capability to use wildcard subdomains for this setup so I wasn't able to fully implement this solution. However, it looks like this would be the best course of action. – Tristan Hall Jun 15 '12 at 14:15

You probably are looking for the directive UserDir

UserDir public_html

This will have apache look for public_html.

For example


will look for the file /home/username/public_html/index.php

  • I am currently using the UserDir directive and I have it set to /home so that users can browse through their files within their home directories. However, once a user has been authenticated they can access everyone's home directories. I want to make it so that they can only access their own home directory. – Tristan Hall Jun 13 '12 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.