Userdir Access On ISPConfig 3 Server

Userdir Access On ISPConfig 3 Server

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.tldif(typeof __ez_fad_position != ‘undefined’){__ez_fad_position(‘div-gpt-ad-howtoforge_com-medrectangle-3-0’)};

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

 

To follow this tutorial you will need the following:

  • a working ISPConfig3 server

 

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.if(typeof __ez_fad_position != ‘undefined’){__ez_fad_position(‘div-gpt-ad-howtoforge_com-medrectangle-4-0’)};

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

 

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/tahder/ispconfig3-userdir/archive/master.zip

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 master
rm master

 

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!

 

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.

 

  • 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.

 

  • ISPConfig3 userdir plugin on Github
  • Apache Module mod_userdir
About the Author

Leave a Reply