Taming Tomcat, Day 3: Security and Perfomance

Author and presenter: Simon Brooke.

The full text of this presentation is online at <URL: http://www.weft.co.uk/library/tomcat/>

Written March-April 2006; $Revision: 1.6 $ of $Date: 2006-04-28$

Changes to the presentation since your handouts were printed are highlighted like this.

Simon Brooke, 21 Main Street, Auchencairn, DG7 1QU, Scotland.

backDay 2: Development and Administration


Programme for Today


Security on the host


File System Security


The JVM and file system security


Recommendations: users and groups


Users and groups: summary

ls -l /var/lib/tomcat4
total 16
dr-xrwx---  2 tomcat  tc-admin 4096 Apr 27 17:35 conf
drwxr-x---  2 tomcat  root     4096 Apr 27 17:35 logs 
drwxr-xr-x  4 root    root     4096 Apr 25 13:46 shared
drwxr-xr-x  2 tomcat  root     4096 Apr 27 17:35 temp
drwsrwsr-x  7 tomcat  webapps  4096 Apr 27 13:41 webapps
drwx------  3 tomcat4 root     4096 Apr 25 16:35 work 

Tomcat's own security


Realms, users and roles


We've encountered these already


Type of Realm


Configuring the Realm


Summing up on Realms


Keeping separate apps separate


The SecurityManager


The SecurityManager (ii)


Permission classes


Custom Permission classes


The policy file(s)


Policy rule syntax


Editing policy files


Debugging policy problems


How secure is security?


Recommendations


Exercise: Set up a Realm authenticated against a database


[Break]


Security on the net


Exposed ports


Exposed ports: what do you have to expose?


Secure Sockets Layer


Brief Introduction to Secure Sockets Layer


Secure Sockets Layer using Apache HTTPD


Secure Sockets Layer using Tomcat directly


Secure Sockets Layer with Tomcat directly: HOWTO


Exercise: Protect one of your Webapps with Secure Sockets Layer


Lunch


Security against failures: Load balancing and failover


Clustering Tomcats


Clustering: Quick HOWTO


Important Gotchas


Session replication


Load Balancing


Load balancing with mod_jk


Load balancing with mod_proxy and mod_rewrite


Load balancing with the balancer webapp


What the documentation doesn't say


balancer webapp rules file: Available classes


balancer webapp rules file: what's missing?


balancer webapp rules file: example

<?xml version="1.0" encoding="UTF-8"?>
<rules>
  <!-- If the URL contains News (case-sensitive), go to CNN.com -->
  <rule className="org.apache.webapp.balancer.rules.URLStringMatchRule"
    targetString="News"
    redirectUrl="http://www.cnn.com" />

  <!-- If the request contains a parameter named paramName whose value
       is paramValue, go to Yahoo.com. -->
  <rule className="org.apache.webapp.balancer.rules.RequestParameterRule"
    paramName="paramName"
    paramValue="paramValue"
    redirectUrl="http://www.yahoo.com" />

  <!-- Redirect all requests to jakarta.apache.org. -->
  <rule className="org.apache.webapp.balancer.rules.AcceptEverythingRule"
    redirectUrl="http://jakarta.apache.org" />
</rules>    

[Break]


Performance Tuning


Tuning and Measurement


Performance of individual components


Profiling your components


Building test-harness Servlets


Generic fixes


Static content


DNS Lookups


Threads


Wrap


Final thought