Jetty在不同端口上分离Web应用程序 [英] Separate webapps in Jetty on different ports

查看:226
本文介绍了Jetty在不同端口上分离Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以下设置。


  • Jetty必须侦听端口 8080 9090

  • 每个端口必须有自己独立的应用程序(即 webapp1 8080 webapp2 9090 )。网络应用程序只能在指定的端口上访问(即 webapp2 一定不能!在端口 8080 上可用。)

  • Jetty must listen on port 8080 and 9090
  • Each port must have its own separate applications (i.e. webapp1 runs on 8080 and webapp2 on 9090). The web-apps should only be accessible on their designated ports (i.e. webapp2 must not! be available on port 8080).

我已成功将额外的连接器添加到etc / jetty.xml,因此它现在使用端口8080和9090.我还添加了额外的处理程序所以它现在从多个目录(dir1 / webapp1和dir2 / webapp2)中获取webaps。

I have successfully added extra connectors to etc/jetty.xml so it now uses port 8080 and 9090. I have also added extra handlers so it now pick ups webaps from multiple directories (dir1/webapp1 and dir2/webapp2).

我的问题是:jetty将每个处理程序找到的所有webapps部署到每个连接器(即每个端口),因此 webapp1 webapp2 都可以在端口 8080 9090 上访问。

My problem is this: jetty deployes all webapps found by each handler to every connector (i.e. every port) and thus webapp1 and webapp2 both becomes accessible on port 8080 and 9090.

我需要一种方法来确保 handler1 (处理dir1 / webapp1)仅指定为 connector1 (侦听在端口8080上)并且同样 connector2 仅在端口 9090 上获取 handler2 (处理dir2 / webapp2)。

I need a way to ensures that handler1 (handles dir1/webapp1) is only designated to connector1 (listens on port 8080) and equally for connector2 to only pick up handler2 (handles dir2/webapp2) on port 9090.

有没有办法实现这个?

推荐答案

Jetty文档显示了两种方法。

第一个配置两个独立的服务器实例,并通过在命令行上提供两个配置文件名来启动它们。

The first configures two separate server instances, and starts them both by supplying the two configuration file names on the command line.

第二种方法使用两个连接器的名称,每个应用程序上下文命名它将使用的连接器。

The second method uses names for the two connectors, and each application context names the connectors it will use.

这篇关于Jetty在不同端口上分离Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆