security_tips.html revision 8ea6a26406513706b84fbb279a1b3faf54760d6f
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen<TITLE>Apache HTTP Server: Security Tips</TITLE>
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen BGCOLOR="#FFFFFF"
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen TEXT="#000000"
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen LINK="#0000FF"
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen VLINK="#000080"
863f2bc9983c33221f5936421fc9c06caf21639aTimo Sirainen ALINK="#FF0000"
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen<!--#include virtual="header.html" -->
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen<H1 ALIGN="CENTER">Security Tips for Server Configuration</H1>
cd18d7bb3e8d5921c3c852bd0a27fbeff9a9babbTimo Sirainen<P>Some hints and tips on security issues in setting up a web server. Some of
ca44a6ba994aaa3231a20ef6e046dfd97a8dcd2dTimo Sirainenthe suggestions will be general, others specific to Apache.
8dec8eab222cb7a0b4ef5e066cb1d7dac8a526d1Timo Sirainen<H2><A name="serverroot">Permissions on ServerRoot Directories</A></H2>
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen<P>In typical operation, Apache is started by the root
ca44a6ba994aaa3231a20ef6e046dfd97a8dcd2dTimo Sirainenuser, and it switches to the user defined by the <A
a64adf62fa33f2463a86f990217b0c9078531a40Timo SirainenHREF="/mod/core.html#user"><STRONG>User</STRONG></A> directive to serve hits.
cd18d7bb3e8d5921c3c852bd0a27fbeff9a9babbTimo SirainenAs is the case with any command that root executes, you must take care
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainenthat it is protected from modification by non-root users. Not only
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainenmust the files themselves be writeable only by root, but so must the
1358e2c58ce29231485a5cfa454756d429ad3d2cTimo Sirainendirectories, and parents of all directories. For example, if you
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainenchoose to place ServerRoot in <CODE>/usr/local/apache</CODE> then it is
c1847a38dfbc8bad29547d96432ef9d707dbd345Timo Sirainensuggested that you create that directory as root, with commands
cd18d7bb3e8d5921c3c852bd0a27fbeff9a9babbTimo Sirainen mkdir bin conf logs
cd18d7bb3e8d5921c3c852bd0a27fbeff9a9babbTimo Sirainen chown 0 . bin conf logs
cd18d7bb3e8d5921c3c852bd0a27fbeff9a9babbTimo Sirainen chgrp 0 . bin conf logs
cd18d7bb3e8d5921c3c852bd0a27fbeff9a9babbTimo Sirainen chmod 755 . bin conf logs
a64adf62fa33f2463a86f990217b0c9078531a40Timo SirainenIt is assumed that /, /usr, and /usr/local are only modifiable by root.
a64adf62fa33f2463a86f990217b0c9078531a40Timo SirainenWhen you install the httpd executable, you should ensure that it is
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainensimilarly protected:
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen<P>You can create an htdocs subdirectory which is modifiable by other
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainenusers -- since root never executes any files out of there, and shouldn't
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainenbe creating files in there.
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainen<P>If you allow non-root users to modify any files that root either
9f0f2de10e4ea0c99052bf4b2bef8179f2536228Timo Sirainenexecutes or writes on then you open your system to root compromises.
a64adf62fa33f2463a86f990217b0c9078531a40Timo SirainenFor example, someone could replace the httpd binary so that the next
conflict (accidentally or deliberately) with other scripts e.g.
HREF="/mod/mod_userdir.html#userdir"
<!--#include virtual="footer.html" -->