简体   繁体   English

使用相同的端口运行多个java jetty实例(80)

[英]running multiple java jetty instances with same port (80)

For Example: 例如:

I am having one primary temp domain 我有一个主要的临时域名

www.product.com

For each client i need to have separate sub domain mapped to same server with same port(80) but with different instance name (different .wars files) 对于每个客户端,我需要将单独的子域映射到具有相同端口(80)但具有不同实例名称(不同.wars文件)的相同服务器

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

(correct me if i am wrong) As i know if i start jetty instance , each will start at seperate port no's (纠正我,如果我错了)我知道如果我启动jetty实例,每个将从单独的端口no开始

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

What my question is how do i map all the instances with port 80 with appropriate identical sub domains 我的问题是如何将端口80的所有实例映射到适当的相同子域

if i access 如果我访问

www.client4.product.com , i need to get jetty app running in port 3004 www.client4.product.com ,我需要在3004端口运行jetty应用程序

Update: 更新:

for more understanding of my architecture , if client2 jetty instance running on port 3002 went to down state due to runtime exception or memory leakage or manual restart , all other jetty instances running independently (similar to architecture behind google appengine uses jetty) 为了更好地理解我的架构,如果在端口3002上运行的client2 jetty实例由于运行时异常或内存泄漏或手动重启而进入关闭状态,则所有其他独立运行的jetty实例(类似于google appengine背后的架构使用jetty)

To do this, don't run multiple Jetty instances. 为此,请不要运行多个Jetty实例。 Run one instance with multiple VirtualHosts. 使用多个VirtualHost运行一个实例。 To do this, you can configure jetty like this: 为此,您可以像这样配置jetty:

  <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>

Check this page out for more information on how to configure this. 有关如何配置此页面的更多信息,请查看此页面

Alternatively, if you really want to have multiple Jetty instances, you can front it with another server like Apache that acts as a reverse proxy. 或者,如果您真的想拥有多个Jetty实例,可以使用另一个像Apache这样充当反向代理的服务器。 Apache can then be set up with virtual hosts by editing your httpd.conf: 然后可以通过编辑httpd.conf来设置Apache虚拟主机:

<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 the apache docs for more info. 您可以查看apache文档以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM