Network filtering:
Place your web server(s) in a DMZ. Set your
firewall to drop connections to your
web server on all ports but http (port 80) or https (port 443).
Host based security:
Remove all unneeded services from your web server, keeping FTP (but only if you need it) and a secure login capability such as secure shell. An unneeded service can become an avenue of attack.
Limit the number of persons having administrator or root level access.
Apply relevant security patches as soon as they are announced and tested on a pre-production system.
Disallow all remote administration unless it is done using a one-time password or an encrypted link.
If the machine must be administered remotely, require that a secure capability such as secure shell is used to make a secure connection. Do not allow telnet or non-anonymous ftp (those requiring a username and password) connections to this machine from any untrusted site. It would also be good to limit these connections only to a minimum number of secure machines and have those machines reside within your Intranet.
Configuring the Web service/application:
If you must use a GUI
interface at the console, remove the commands that automatically start the window manager from the .RC startup directories and then create a startup command for the window manager. You can then use the window manager when you need to work on the system, but shut it down when you are done. Do not leave the window manager running for any extended length of time.
Run the web server in a chroot-ed part of the directory tree so it cannot access the real system files.
Run the anonymous FTP server (if you need it) in a chroot-ed part of the directory tree that is different from the web server's tree.
Remove ALL unnecessary files such as phf from the scripts directory /cgi-bin.
Remove the "default" document trees that are shipped with Web servers such as IIS and ExAir.
Apply relevant security patches as soon as they are announced and tested on a pre-production system.
Auditing/logging:
Log all user activity and maintain those logs either in an encrypted form on the web server or store them on a separate machine on your Intranet, or write to "write-once" media.
Monitor system logs regularly for any suspicious activity.
Install some trap macros to watch for attacks on the server (such as the PHF attack).
Create macros that run every hour or so that would check the integrity of passwd and other critical files.
When the macros detect a change, they should send an e-mail to the system manager, write a message to logs, set off a pager, etc..
Content management:
Do all updates from your Intranet. Maintain your web page originals on a
server on your Intranet and make all changes and updates here; then "push" these updates to the public server through an SSH or SSL connection. If you do this on a hourly basis, you can avoid having a corrupted server exposed for a long period of time.
Write a script to download HTML pages and check against a template, if changes are noted, upload the correct version.
Intrusion Detection:
Scan your web server periodically with tools like ISS, Nmap, Nessus or Satan to look for vulnerabilities.
Have intrusion detection software monitor the connections to the server. Set the detector to alarm on known exploits and suspicious activities and to capture these sessions for review. This information can help you recover from an intrusion and strengthen your defenses.