使用 Weblogic 代理和 Apache2 将 https 请求重定向到两个不同的 weblogic 服务器

发布于 2024-08-18 18:14:12 字数 1006 浏览 9 评论 0原文

我有一个服务器 serverA,在端口 7001 上运行 weblogic 应用程序 App1,基本 url /app1/,另一个服务器 serverB,在端口 8001 上运行 weblogic 应用程序 App2,基本 url /app2/。两台服务器都运行 Solaris、Apache2 和 Weblogic 9.2

(细节有所更改,但这些具有代表性)

换句话说,可以通过

http://serverA:7001/ 上的app1/

和 app2

访问 app1 http://serverB:8001/app2/

但是,客户要求对应用程序的所有访问都使用端口 443 上的 https 到 server1。

如果只有一个应用程序,我可以使用虚拟主机,并将以 /app1/ 开头的 URL 的处理程序设置为 Weblogic 代理,该代理会将它们转发到端口 7001 上的服务器 1。

对于两个应用程序,我需要另一个虚拟主机主机与另一个位置语句匹配 /app2/ 并转发到端口 8001 上的当前服务器...但我不明白这是如何工作的,因为第一个虚拟主机将完成 SSL 协商以确定 URL,并且 Apache 大概当事情落到第二个虚拟服务器上时,就无法再这样做了。

那么我该如何处理这个问题呢?

我当前的想法是将所有到达 server1 的 SSL 请求代理到同一服务器 server1 的端口 80(因此本质上只是执行 SSL 终止),然后以上述方式为 /app1/ 和 /app2/ URL 添加两个虚拟主机。

这行得通吗?我是否错过了其他执行此操作的明显方法?

编辑:我想我可能错过了 Weblogic 插件可以有多个块,每个块将页面定向到不同的位置。在这种情况下,这变得很容易。

我明天回来工作后会测试并更新问题

I have a server serverA running a weblogic application App1, with base url /app1/ on port 7001, and another server serverB, running a weblogic application App2, with base url /app2/ on port 8001. Both servers run Solaris, Apache2 and Weblogic 9.2

(details changed, but these are representantive)

In other words, app1 could be accessed on

http://serverA:7001/app1/

and app2 on

http://serverB:8001/app2/

However, the customer requires that all access to the applications use https on port 443 to server1.

If there was only one application, I could use a virtual host and set the handler for URLS beginning with /app1/ to the Weblogic proxy, which would forward them on to server 1 on port 7001.

With two apps, I would need another virtual host with another Location statement matching /app2/ and forwarding to the current server on port 8001 ... but I don't see how this could work as the first virtual host will have done the SSL negotiation to determine the URL, and Apache presumably can't do that over when things fall through to the second virtual server.

So how do I handle this?

My current idea is to proxy all SSL requests arrving at server1 to the same server server1, on port 80 (so essentially just doing SSL termination), then adding two virtual hosts for the /app1/ and /app2/ URLs in the way described above.

Is this going to work? Have I missed something obvious about other ways of doing this?

EDIT: I think I may have missed that the Weblogic plugin can have several blocks each directing the page to different places. In which case this becomes easy.

I will test tomorrow when back at work and update the question

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

还在原地等你 2024-08-25 18:14:12

首先,必须阅读的资源当然是官方文档: 安装和配置 Apache HTTP Server 插件(另请参阅此之前的答案,了解有关 WLS 9 插件的更多链接)。

配置 Apache HTTP Server 部分中详细介绍的插件,我定义了几个 IfModule,每个应用程序一个(集群或非集群),并且实际上定义了几个 VirtualHost (其中可以包括 <代码>IfModule)。有示例文档:

<前><代码># VirtualHost1 = localhost:80
<虚拟主机 127.0.0.1:80>
文档根目录“C:/test/VirtualHost1”
服务器名称 localhost:80
#...WLS 参数...
WebLogicCluster 本地主机:7101,本地主机:7201
# 示例:MatchExpression *.jsp <一些附加参数>;
MatchExpression *.jsp PathPrepend=/test2

# 虚拟主机2 = 127.0.0.2:80
<虚拟主机 127.0.0.2:80>
文档根目录“C:/test/VirtualHost1”
服务器名称 127.0.0.2:80
;
#...WLS 参数...
WebLogicCluster 本地主机:7101,本地主机:7201
# 示例:MatchExpression *.jsp <一些附加参数>;
MatchExpression *.jsp PathPrepend=/test2
#...WLS 参数...

;

请注意,这是一个基于多个 IP 的虚拟主机配置(而不是文档中所述的基于名称)。但这实际上很好,因为这正是您在使用 SSL 时所需要的,因为您不能使用基于名称的虚拟主机。引用 为什么我不能将 SSL 与基于名称/非 IP 一起使用基于 -based 的虚拟主机? 来自 Apache 的 SSL/TLS 强加密:常见问题解答

原因非常技术性,有点“先有鸡还是先有蛋”的问题。 SSL协议层位于HTTP协议层之下,对HTTP进行封装。当建立 SSL 连接 (HTTPS) 时,Apache/mod_ssl 必须与客户端协商 SSL 协议参数。为此,mod_ssl 必须查阅虚拟服务器的配置(例如,它必须查找密码套件、服务器证书等)。但为了访问正确的虚拟服务器,Apache 必须知道 Host HTTP 标头字段。为此,必须读取 HTTP 请求标头。在 SSL 握手完成之前无法完成此操作,但需要该信息才能完成 SSL 握手阶段。宾果游戏!

因此,在上面的示例中,修改虚拟主机 IP 地址和端口、ServerName,调整 IfModule 以满足您的需求(并设置 DNS 条目以指向 IP),然后就可以了。

First, the must read resource for this is of course the official documentation : Installing and Configuring the Apache HTTP Server Plug-In (see also this previous answer for more links about the WLS 9 plugin).

As detailed in the section Configuring the Apache HTTP Server Plug-In, I'd define several IfModule, one for each application (clustered or not), and, indeed, several VirtualHost (which can include IfModule). There is an example in the documentation:

# VirtualHost1 = localhost:80
<VirtualHost 127.0.0.1:80>
  DocumentRoot "C:/test/VirtualHost1"
  ServerName localhost:80 <IfModule mod_weblogic.c> 
  #... WLS parameter ...
  WebLogicCluster localhost:7101,localhost:7201
  # Example: MatchExpression *.jsp <some additional parameter>
  MatchExpression *.jsp PathPrepend=/test2
  </IfModule>
</VirtualHost>

# VirtualHost2 = 127.0.0.2:80
<VirtualHost 127.0.0.2:80>
  DocumentRoot "C:/test/VirtualHost1"
  ServerName 127.0.0.2:80
  <IfModule mod_weblogic.c> 
  #... WLS parameter ...
  WebLogicCluster localhost:7101,localhost:7201
  # Example: MatchExpression *.jsp <some additional parameter>
  MatchExpression *.jsp PathPrepend=/test2
  #... WLS parameter ...
  </IfModule>
</VirtualHost>    <IfModule mod_weblogic.c>

Note that this is a Multiple IP-Based Virtual Hosts configuration (and not Name-Based as stated in the documentation). But this is actually good because this is exactly what you need when using SSL as you can't use name-based virtual hosts. Quoting Why can't I use SSL with name-based/non-IP-based virtual hosts? from Apache's SSL/TLS Strong Encryption: FAQ

The reason is very technical, and a somewhat "chicken and egg" problem. The SSL protocol layer stays below the HTTP protocol layer and encapsulates HTTP. When an SSL connection (HTTPS) is established Apache/mod_ssl has to negotiate the SSL protocol parameters with the client. For this, mod_ssl has to consult the configuration of the virtual server (for instance it has to look for the cipher suite, the server certificate, etc.). But in order to go to the correct virtual server Apache has to know the Host HTTP header field. To do this, the HTTP request header has to be read. This cannot be done before the SSL handshake is finished, but the information is needed in order to complete the SSL handshake phase. Bingo!

So, in the sampel above, modify the virtual hosts IP addresses and ports, the ServerName, adapt the IfModule to suit your needs (and set up DNS entries to point on the IPs) and there you go.

幸福还没到 2024-08-25 18:14:12

我没有任何 weblogic 的经验,所以也许我错过了一些重要的东西。但这听起来像是 apache 反向代理功能的一个简单应用程序。设置一个服务 https 的 apache 实例,并配置两个位置,如下所示:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

<Location /app1>
    ProxyPass http://serverA:7001/app1
    ProxyPassReverse http://serverA:7001/app1
</Location>
<Location /app2>
    ProxyPass http://serverB:8001/app2
    ProxyPassReverse http://serverB:8001/app2
</Location>

I don't have any experience with weblogic, so maybe I'm missing something important. But this sounds like a straightforward application for apache's reverse proxy capability. Set up an apache instance serving https, and configure two locations as follows:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

<Location /app1>
    ProxyPass http://serverA:7001/app1
    ProxyPassReverse http://serverA:7001/app1
</Location>
<Location /app2>
    ProxyPass http://serverB:8001/app2
    ProxyPassReverse http://serverB:8001/app2
</Location>
七婞 2024-08-25 18:14:12

WebLogic 10.3.x 文档中的示例配置 非常适合您的问题。这里添加了一些其他细节:

<VirtualHost _default_:443>
  SSLEngine on
  # other SSL options here...

  LoadModule weblogic_module /home/Oracle/Middleware/wlserver_10.3/server/plugin/linux/x86_64/mod_wl_22.so

  <IfModule mod_weblogic.c>

    <Location /app1>
      WebLogicHost serverA
      WebLogicPort 7001
      SetHandler weblogic-handler
    </Location>

    <Location /app2>
      WebLogicHost serverB
      WebLogicPort 8001
      SetHandler weblogic-handler
    </Location>

  </IfModule>
</VirtualHost>

我使用它并且工作正常。

The example config from the WebLogic 10.3.x documentation is a perfect fit for your question. Here it is with some other details added:

<VirtualHost _default_:443>
  SSLEngine on
  # other SSL options here...

  LoadModule weblogic_module /home/Oracle/Middleware/wlserver_10.3/server/plugin/linux/x86_64/mod_wl_22.so

  <IfModule mod_weblogic.c>

    <Location /app1>
      WebLogicHost serverA
      WebLogicPort 7001
      SetHandler weblogic-handler
    </Location>

    <Location /app2>
      WebLogicHost serverB
      WebLogicPort 8001
      SetHandler weblogic-handler
    </Location>

  </IfModule>
</VirtualHost>

I use this and works fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文