Running multiple instances of java consoles with the same port (80)

Example:

I have one primary domain temp

www.product.com 

For each client, I must have a separate subdomain associated with the same server with the same port (80), but with a different instance name (different .wars files)

 www.client1.product.com www.client2.product.com www.clientn.product.com 

(correct me if I am wrong). As I know, if I start a mooring instance, each will start from a separate port no

 client1 war will start at port 3001 client2 war will start at port 3002 client3 war will start at port 3003 

What is my question: how do I map all instances with port 80 to the corresponding identical subdomains

if i access

www.client4.product.com , I need the berth application to work in port 3004

Update:

for a deeper understanding of my architecture, if a Jet2 Jetty instance running on port 3002 goes into standby due to a runtime exception or a memory leak or a manual restart, all other berth instances work independently (similar to the architecture used by google appengine it uses a berth)

+6
source share
1 answer

To do this, do not run multiple instances of Jetty. Launch one instance with multiple VirtualHosts. To do this, you can configure the pier as follows:

  <Configure class="org.eclipse.jetty.webapp.WebAppContext"> <Set name="war"><SystemProperty name="jetty.home"/>/webapps/client1.war</Set> <Set name="contextPath">/</Set> <Set name="virtualHosts"> <Array type="java.lang.String"> <Item>www.client1.product.com</Item> </Array> </Set> </Configure> <Configure class="org.eclipse.jetty.webapp.WebAppContext"> <Set name="war"><SystemProperty name="jetty.home"/>/webapps/client2.war</Set> <Set name="contextPath">/</Set> <Set name="virtualHosts"> <Array type="java.lang.String"> <Item>www.client2.product.com</Item> </Array> </Set> </Configure> 

Open this page for more information on how to configure this.

Alternatively, if you really want to have multiple instances of Jetty, you can run it from another server, such as Apache, which acts as a reverse proxy. Apache can then be configured using virtual hosts by editing your httpd.conf:

 <VirtualHost *:80> ServerName www.client1.product.com ProxyRequests off ProxyPass / http://someInternalHost:3001/ ProxyPassReverse / http://someInternalHost:3001/ </VirtualHost> <VirtualHost *:80> ServerName www.client2.product.com ProxyRequests off ProxyPass / http://someInternalHost:3001/ ProxyPassReverse / http://someInternalHost:3001/ </VirtualHost> 

You can see apache docs for more information.

+7
source

Source: https://habr.com/ru/post/924113/


All Articles