Download Securing Debian Manual
Transcript
161 Appendix H Chroot environment for Apache H.1 Introduction The chroot utility is often used to jail a daemon in a restricted tree. You can use it to insulate services from one another, so that security issues in a software package do not jeopardize the whole server. When using the makejail script, setting up and updating the chrooted tree is much easier. FIXME: Apache can also be chrooted using http://www.modsecurity.org which libapache-mod-security (for Apache 1.x) and libapache2-mod-security (for Apache 2.x). H.1.1 is available in Licensing This document is copyright 2002 Alexandre Ratti. It has been dual-licensed and released under the GPL version 2 (GNU General Public License) the GNU-FDL 1.2 (GNU Free Documentation Licence) and is included in this manual with his explicit permission. (from the original document (http://www.gabuzomeu.net/alex/doc/apache/index-en.html)) H.2 Installing the server This procedure was tested on Debian GNU/Linux 3.0 (Woody) with makejail 0.0.4-1 (in Debian/testing). • Log in as root and create a new jail directory: $ mkdir -p /var/chroot/apache • Create a new user and a new group. The chrooted Apache server will run as this user/group, which isn’t used for anything else on the system. In this example, both user and group are called chrapach. $ adduser --home /var/chroot/apache --shell /bin/false \ --no-create-home --system --group chrapach FIXME: is a new user needed? (Apache already runs as the apache user) • Install Apache as usual on Debian: apt-get install apache • Set up Apache (e.g. define your subdomains, etc.). In the /etc/apache/httpd.conf configuration file, set the Group and User options to chrapach. Restart Apache and make sure the server is working correctly. Now, stop the Apache daemon. • Install makejail (available in Debian/testing for now). You should also install wget and lynx as they will be used by makejail to test the chrooted server: apt-get install makejail wget lynx • Copy the sample configuration file for Apache to the /etc/makejail directory: # cp /usr/share/doc/makejail/examples/apache.py /etc/makejail/