Search: Advanced search
|
Browse by category:
|
Glossary |
Search: Advanced search
|
Browse by category:
|
Glossary |
20 ways to Secure your Apache Configuration |
|||||
Republished with permission, from http://www.petefreitag.com/item /505.cfm by Pete Freitag. Here are 20 things you can do to make your Apache configuration more secure. Disclaimer: The thing about security is that there are no guarantees or absolutes. These suggestions should make your server a bit tighter, but don't think your server is necessarily secure after following these suggestions. Additionally some of these suggestions may decrease performance, or cause problems due to your environment. It is up to you to determine if any of the changes I suggest are not compatible with your requirements. In other words proceed at your own risk. First, make sure you've installed latest security patchesThere is no sense in putting locks on the windows, if your door is wide open. As such, if you're not patched up there isn't really much point in continuing any longer on this list. Go ahead and bookmark this page so you can come back later, and patch your server. Hide the Apache Version number, and other sensitive information.By default many Apache installations tell the world what version of Apache you're running, what operating system/version you're running, and even what Apache Modules are installed on the server. Attackers can use this information to their advantage when performing an attack. It also sends the message that you have left most defaults alone. There are two directives that you need to add, or edit in your ServerSignature Off The The Server: Apache If you're super paranoid you could change this to something other than "Apache" by editing the source code, or by using mod_security (see below). Make sure apache is running under its own user account and groupSeveral Apache installations have it run as the user User apache Ensure that files outside the web root are not servedWe don't want Apache to be able to access any files out side of its web root. So assuming all your web sites are placed under one directory (we will call this <Directory /> Note that because we set Turn off directory browsingYou can do this with an Options -Indexes Turn off server side includesThis is also done with the Options -Includes Turn off CGI executionIf you're not using CGI turn it off with the Options -ExecCGI Don't allow apache to follow symbolic linksThis can again can be done using the Options -FollowSymLinks Turning off multiple OptionsIf you want to turn off all Options None If you only want to turn off some separate each option with a space in your Options -ExecCGI -FollowSymLinks -Indexes Turn off support for .htaccess filesThis is done in a AllowOverride None If you require Overrides ensure that they cannot be downloaded, and/or change the name to something other than AccessFileName .httpdoverride Run mod_securitymod_security is a super handy Apache module written by Ivan Ristic, the author of Apache Security from O'Reilly press. You can do the following with mod_security:
Disable any unnecessary modulesApache typically comes with several modules installed. Go through the Apache module documentation and learn what each module you have enabled actually does. Many times you will find that you don't need to have the said module enabled. Look for lines in your grep LoadModule httpd.conf Here are some modules that are typically enabled but often not needed: Make sure only root has read access to apache's config and binariesThis can be done assuming your Apache installation is located at chown -R root:root /usr/local/apache Lower the Timeout valueBy default the Timeout 45 Limiting large requestsApache has several directives that allow you to limit the size of a request, this can also be useful for mitigating the effects of a denial of service attack. A good place to start is the LimitRequestBody 1048576 If you're not allowing file uploads you can set it even smaller. Some other directives to look at are Limiting the size of an XML BodyIf you're running LimitXMLRequestBody 10485760 Limiting ConcurrencyApache has several configuration settings that can be used to adjust handling of concurrent requests. The Other directives such as Restricting Access by IPIf you have a resource that should only by accessed by a certain network, or IP address you can enforce this in your Apache configuration. For instance if you want to restrict access to your intranet to allow only the 176.16 network:
Or by IP: Order Deny,Allow Adjusting KeepAlive settingsAccording to the Apache documentation using HTTP Keep Alive's can improve client performance by as much as 50%, so be careful before changing these settings, you will be trading performance for a slight denial of service mitigation. KeepAlive's are turned on by default and you should leave them on, but you may consider changing the Run Apache in a Chroot environment
It can be fairly tricky to set this up using SecChrootDir /chroot/apache There are however some caveats however, so check out the docs for more info. AcknowledgmentsI have found the book Apache Security to be a highly valuable resource for securing an Apache web server. Some of the suggestions listed above were inspired by this book. Copyright ©2007 Pete Freitag http://www.petefreitag.com/ Please Note: |
|||||
Copyright © 2000 - 2008 Mambo Foundation, Inc | Reg. No. A0047564G | Terms of Use | Privacy Policy
Mambo® and the Mambo logos are trademarks of the Mambo Foundation, Inc.
Managed Servers by DedicatedNOW