Secure shared web hosting on Ubuntu Server, part 1

We’ve gone over securing a shared hosting setup briefly in the past, but I have made some improvements and simplifications that I’d like to share. This is part 1 of 3, an introduction to secure shared web hosting on Ubuntu Server.

At AnyHosting we want to have multiple users on one shared server, but protect them from reading or writing each other’s files (whether accidental or intentional) and also limit damage caused by a break-in via a poorly configured PHP script or CGI, or even an Apache exploit.

The solution here is to have each customer run their own Apache process, and do name-based virtual hosting and forwarding via a reverse proxy. The proxy is currently Apache but we are also considering more scalable alternatives such as nginx. An important thing to note here is that the proxy could be on a separate machine and also combine load-balancing into the mix, so it provides a lot of flexibility.

The classic way to chroot Apache (or any server process) is to copy the server process and all of it’s dependencies into the chroot jail, which makes keeping the files up to date not just a depressing chore but also a serious security hazard. Also it’s a ton of work to get right, especially if you want to support server-side scripting like PHP, since it depends on lots of system files and libraries.

Enter mod_chroot. This Apache module runs in the user’s process, and does the chroot system call after opening all the files it needs. The only caveats I’ve found (besides the ones on the mod_chroot caveats page) are some files that the Ubuntu PHP install assumes it can reach (such as the MySQL server socket, timezone info, and random number generator). I will cover this in more detail in part 2.

UPDATE link to secure shared hosting on ubuntu server part 2

3 Responses to “Secure shared web hosting on Ubuntu Server, part 1”

  1. AnyHosting » Blog Archive » Secure shared web hosting on Ubuntu Server, part 2 Says:

    [...] Contact « Secure shared web hosting on Ubuntu Server, part 1 [...]

  2. AnyHosting » Blog Archive » monitoring ubuntu web servers with nagios3 Says:

    [...] line; anyhosting1 is the physical server (this monitor is really checking on the reverse proxy), and example.com is a vhost (which is really proxying to a user running Apache for the [...]

  3. AnyHosting » Blog Archive » web hosting with ubuntu server Says:

    [...] UPDATE link to the first article on secure shared hosting [...]

Leave a Reply