Userdir Access On ISPConfig 3 Server

Want to support HowtoForge? Become a subscriber!
 
Submitted by MaddinXx (Contact Author) (Forums) on Wed, 2012-08-22 17:12. :: ISPConfig | Web Server | Apache | Control Panels

Userdir Access On ISPConfig3 Server

Version 1.0
Author: Michel Käser <info [at] rackster [dot] ch>
Last edited 05/09/2012

This tutorial describes how you can enable userdir based access on your ISPConfig3 server running apache2.

At the end, your clients will be able to access their site via http://yourdomain.tld/~clientdomain.tld

I do not issue any guarantee that this will work for you!

 

1 Requirements

To follow this tutorial you will need the following:

  • a working ISPConfig3 server

 

2 Preparing Apache2

Before we can install the ISPConfig3 plugin, we have to prepare the apache2 webserver. It's very easy.

First of all, you have to enabled the mod_userdir module by typing:

a2enmod userdir

Since we don't want to use the modules default configuration, we simply delete it's content (otherwise usedir access would be possible from all domains):

echo "" > /etc/apache2/mods-available/userdir.conf

However, apache2 now doesn't have a config for userdir anymore, so we add it again.

Open the file /etc/apache2/sites-available/default with an editor of your choice (e.g. nano) and append the following lines within the vhost directive:

[...]
<IfModule mod_userdir.c>
	UserDir /var/www/*/web
	UserDir disabled

	Include /etc/apache2/userdirs-enabled/*

	<Directory /var/www/*/web>

		AllowOverride FileInfo AuthConfig Limit Indexes
		Options MultiViews SymLinksIfOwnerMatch IncludesNoExec

		<Limit GET POST OPTIONS>
			Order allow,deny
			Allow from all
		</Limit>

		<LimitExcept GET POST OPTIONS>
			Order deny,allow
			Deny from all
		</LimitExcept>

		# Disallow PHP file access
		<Files ~ '.php[s3-6]{0,1}$'>
			Order allow,deny
			Deny from all
			Allow from none
		</Files>

	</Directory>
</IfModule>
[...]

and save the file.

Last but not least we need to create two folders into which the plugin will save it's files (equal to sites-available and sites-enabled):

mkdir /etc/apache2/userdirs-available
mkdir /etc/apache2/userdirs-enabled

Finally, restart apache:

/etc/init.d/apache2 restart

 

3 Installing The Plugin

Now it's time to install the plugin itself, as for now, userdir doesn't to anything.

 

Download The Plugin

It's always good to have temporary files within /tmp so go there:

cd /tmp

and download the plugin:

wget https://github.com/Rackster/ispconfig3-userdir/zipball/stable

Note that the last part of the URL (e.g *stable*) stands for the branch.
We have *master*, *stable* and *experimental* but you should always take *stable*, as this contains a version that's working fine.

Now, unpack the files by running:

unzip stable
rm stable

 

Copy The Files

OK, as you now have all the file on the server's disk, it's time to copy them to the correct paths. Therefore we first change into the newly created folder:

cd Rackster-ispconfig3-userdir-*

and copy the files:

cp usr/local/ispconfig/server/plugins-available/apache2_userdir_plugin.inc.php /usr/local/ispconfig/server/plugins-available/
cp usr/local/ispconfig/server/conf/apache2_userdir.conf.master /usr/local/ispconfig/server/conf/

Do the same for all files within the interface folder. You may need to delete existing files first.

If your setup is already modified, it might be smart to manually apply the changes. To do so, just take a loot at https://github.com/Rackster/ispconfig3-userdir/commit/777177b6c768c1f3777bf7d70443e3f8483820b8 to see what files were changed.

Done! We no longer need the downloaded files, so we can delete them:

rm -rf /tmp/Rackster-ispconfig3-userdir-*

However, the plugin uses a class which was taken from another plugin, so you have to create a folder and file for it to work:

mkdir /usr/local/ispconfig/server/plugins-available/classes

and create a file called vhost.php within this folder:

nano /usr/local/ispconfig/server/plugins-available/classes/vhost.php

and paste the content of this file into it: https://raw.github.com/Rackster/ispconfig3-nginx-reverse-proxy/master/usr/local/ispconfig/server/plugins-available/classes/vhost.php

 

Add The DB Field

The plugin needs another field in the ISPConfig Database, you have to create it. The easiest way is to login into phpMyAdmin:

select ISPConfig DB -> select table web_domain -> add new field after "errordocs" -> name: userdir, type: tinyint, length: 1, default: 0

 

CHMOD The Files

Just run:

chmod 750 /usr/local/ispconfig/server/conf/apache2_userdir.conf.master
chmod 750 /usr/local/ispconfig/server/plugins-available/apache2_userdir_plugin.inc.php

to set correct rights.

 

Enable The Plugin

ISPConfig looks in /usr/local/ispconfig/server/plugins-enabled for enabled plugins, so we have to create a symlink there:

cd /usr/local/ispconfig/server/plugins-enabled/
ln -s /usr/local/ispconfig/server/plugins-available/apache2_userdir_plugin.inc.php

That's all!

 

4 Using The Plugin

If you followed all steps from above, you should now see another "field" called Temporary URL within the sites module. To enable userdir based access for a domain, just activate the checkbox next to it.

The client will then be able to access his site by typing: http://yourdomain.tld/~hisdomain.tld in the browser.

 

5 Notes

  • For security reasons, PHP is completely disabled when accessing a site via its userdir URL.
  • This might only be useful for sites using HTML/CSS/JS only.
  • Make sure to check out the repository on GitHub from time to time to check if there were additional changes.

 

6 Links


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Fri, 2014-10-17 12:53.

Hello, 

 I would like to set the user_dir module in my server via this method, but the file https://raw.github.com/Rackster/ispconfig3-nginx-reverse-proxy/master/usr/local/ispconfig/server/plugins-available/classes/vhost.php deosn't seem to be available.

Does anypne still have the file and the plugin?

Thank you

 

Submitted by ally (not registered) on Mon, 2013-07-22 09:09.

(Going to answer the question I posted previously)

 This also works for nginx + IspConfig3 + CentOs6.3.  If on nginx, skip all the apache parts and do this http://wiki.nginx.org/NginxUserDir  (changing the "/home/$1/public_html$2;" part to whatever is your dir structure). Then proceed to install the plugin as directed, except I used the source link from github page to download the plugin as the link posted here no longer works.

 Also, what worked for me is http://yourdomain.com/~otherdomain.com/index.html  (specifying page you want to see else you get a forbidden error even if you turn autoindex on).

Submitted by ally (not registered) on Mon, 2013-07-22 08:12.
Is it possible to do this with nginx + ispconfig3 +centos?
Submitted by Szymon (not registered) on Tue, 2012-12-25 12:51.

Hi!

Is possible enable executing php scripts in userdir?

Submitted by MaddinXx (registered user) on Fri, 2012-12-28 12:15.
I's possible by commenting the apache directive disallowing access to files ending with .php* - it's however not recommended.