I'm developing a web application, which consists of two independent parts - the authentication and the real application part. Both parts are WAR
s which are deployed at (currently) one Tomcat 7 instance.
So, I have the following two WAR
s in my webapps
folder:
webapps
|
+- BloggofantAuthentication
|
+- Bloggofant
until now they are available at http://127.0.0.1:8080/BloggofanAuthentication
and http://127.0.0.1:8080/Bloggofant
. Is it possible proxy the WAR
s at Tomcat directly (so that I don't have to use Apache httpd
and its mod_proxy
module)? So that in the end, the WAR
s at the server are reachable as follows:
http://127.0.0.1:8080/BloggofantAuthentication
--> http://127.0.0.1/bloggo/
http://127.0.0.1:8080/Bloggofant
--> http://127.0.0.1/bloggo/fant/
Any suggestions on this topic are highly appreciated ;)
Here are the context.xml
files of the two unpacked webapp WAR folders:
webapps/BloggofantAuthentication/META-INF/context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context path="">
<!-- Comment this to enable session persistence across Tomcat restarts -->
<Manager pathname=""/>
</Context>
webapps/Bloggofant/META-INF/context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/bloggofant">
<!-- Comment this to enable session persistence across Tomcat restarts -->
<Manager pathname=""/>
</Context>
If I now want to access my apps via http://127.0.0.1:8080
or http://127.0.0.1:8080/bloggofant
I get a 404 - Page Not Found error ...
You can configure the path at which Tomcat serves a web application using a context.xml file . You can put this in the WAR's META-INF directory, with the content:
<Context path="/bloggo/fant" />
And it will serve it there instead of at the default /Bloggofant
path.
Note the warning about automatic deployment in the documentation:
When autoDeploy or deployOnStartup operations are performed by a Host, the name and context path of the web application are derived from the name(s) of the file(s) that define(s) the web application. Consequently, the context path may not be defined in a META-INF/context.xml embedded in the application
Elsewhere, the documentation tells us that these both default to true . Thus, you will need to set them to false for these settings to be respected.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.