I would like to restrict one of my web services running under Tomcat 7. That is, I have one instance of Tomcat 7 hosting several web services. Some of these web services need not be restricted to a specific IP-address, so this restriction must be per-app.
Initial search on the subject suggests that it is possible to do so via a Remote Address Filter by adding something like:
<Context>
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="10\.180\.156\.159"/>
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1"/>
</Context>
in "some" XML file that is part of the deployed WAR file.
My problem is that "some XML file" is very confusingly named. My understanding is that it is supposed to be the context XML but the context XML can be named anything... (it looks like the <param-name>contextConfigLocation</param-name>
in <context-param>
in web.xml
that determines the name)
So, in the various sources providing the tips to implement this restriction, the references were to:
- META-INF/context.xml (my WAR has no META-INF subfolder, only WEB-INF)
- WEB-INF/web.xml (I do have that file, but it is the file that points to the context XML, not the context XML itself)
- conf\Catalina\localhost\manager.xml (looks tomcat-wide, not per-app)
My context XML is named beans.xml
and is located in the WEB-INF/classes
subfolder...
Can someone please clarify this issue?
I am going to experiment now with my own guess, but an authoritative answer would be nice.