Running two web applications on same port?

2019-07-16 10:23发布

问题:

We have two different Java web apps named foo.war and bar.war and we want to deploy these on Jetty server

Jetty is running on 8080 port on the machine

Is it possible simultaneously run two apps on same port ? If no what are the alternatives to run multiple web apps on same jetty server

Thanks

回答1:

You can run as many web applications as you want in a servlet container. They just need different context roots.

Let's say you have abc.war and def.war. If you deploy both, by default you can access them through http://localhost:8080/abc and http://localhost:8080/def.

Since this usually looks ugly, it's a good idea to put a reverse proxy in front of your Servlet container. This will allow you to have for example 2 different domains foobar.com and xipbaz.com that will then be routed to different applications, even if they're all on the same server.