I'm developing a webapp using Apache Tomcat. This webapp will be deployed in a server which hosts other webapps. Now, since my webapp requires the user to authenticate, I'd need to modify some files in the "conf" directory of Tomcat such as "tomcat-users.xml". The problem is that these files are shared with the other webapps. Is there a way to have a "conf" directory for my webapp which is separated from the shared one? Thank you.
Tomcat allows you to separate out configuration from the main server.xml by creating an xml file underneath $CATALINA_BASE/conf/[enginename]/[hostname] called [YourWebappName].xml.
For example: $CATALINA_BASE/conf/Catalina/localhost/PetClinic.xml
This file bascially contains a <Context> element defining the webapp specific context configuration. In here you can define your own webapp specific realm with the necessary authentication parameters for your app.
This mechanism is designed so that you can modify webapp specific configuration without touching the top-level shared files in Tomcat's conf folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With