Reputation: 6602
I know I can set tomcat to accept just local connections by editing its configuration files and setting an address there. However, this setting will be applied to every web application I decide to run on it.
I'd like for just a specific web application to accept connections by localhost, maybe returning a default html page in case of a remote connection.
Is that possible?
Upvotes: 1
Views: 98
Reputation: 218
you could write a servlet filer and map the resources you need to protect, here is some code you will need:
String host = request.getRemoteHost();
String address = request.getRemoteAddr();
if ("localhost".equals(host) || "127.0.0.1".equals(address)) {
//Accept connecction
}else{
//reject connection
}
Make sure the configuration of a reverse proxy in from of tomcat does not mark all the connection as locals! A DNS spoofing brakes it, but it is very unlikely to corrupt your host file!
Upvotes: 1