Adapted from http://rod.vagg.org/2011/07/handling-x-forwarded-for-in-java-and-tomcat/