开发者

Move Tomcat Root

When I start up tomcat, it starts serving out of localhost:8080/. I would like it to st开发者_如何学Pythonart serving out of localhost:8080/aaa. I dont want to replace the "root" webapp with the "aaa" webapp, I want tomcat to treat "/aaa" like "/" in the sense that before where I could do something like

  • localhost:8080/ --> root webapp
  • localhost:8080/webapp1 --> webapp1
  • etc.

I now want to do something like:

  • localhost:8080/aaa ---> root webapp
  • localhost:8080/aaa/webapp1 --> webapp1
  • etc.

Any help would be great.


I am not sure if you can do this with Tomcat only, but this is usually achieved with Apache mod_proxy.


There is a solution but this is an ugly one and not recommended by Tomcat docs (i.e. adding Context in server.xml is not recommended). This is okay for you to test out on your current server.

You can set these in your Tomcat server.xml.

Add a <Context> element within the <Host> like below and set the path as your "/aaa" prefix

This should allow you to access http: //localhost:8080/aaa will directly take you to webapp "root"

<Context docBase="rootwebapp" path="/aaa" reloadable="true"  />

Add another Context with the path to "/aaa/webapp1" like below should allow you to access webapp1 as http: //localhost:8080/aaa/webapp1

<Context docBase="webapp1" path="/aaa/webapp1" reloadable="true"  />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜