English 中文(简体)
Redirecting https requests to two different weblogic servers using the Weblogic proxy and Apache2
原标题:

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

最佳回答

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.

问题回答

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>

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.





相关问题
Portable way to get file size (in bytes) in the shell

On Linux, I use stat --format="%s" FILE, but the Solaris machine I have access to doesn t have the stat command. What should I use then? I m writing Bash scripts and can t really install any ...

Unix: fast remove directory for cleaning up daily builds

Is there a faster way to remove a directory then simply submitting rm -r -f *directory* ? I am asking this because our daily cross-platform builds are really huge (e.g. 4GB per build). So the ...

Startup time in Solaris server using shell script

How to find the start up time of a Solaris 5.1 server using a shell script,need to know how much time it took to be on running state?I need to know how much time it took to come to running mode from ...

Ruby 1.8.6 BigDecimal.to_f always returns 0,0 on Solaris

I have come across a very weird error. I m on Solaris 10, using Ruby Enterprise Edition (ruby 1.8.6 (2008-08-08 patchlevel 286) [i386-solaris2.10]) with Rails 2.3.4. I have a very weird error. In irb: ...

Where to set JDK to be used for SunOne server?

Where to set the JDK to be used by the SunOne server on Solaris? Is it all configured via an environment variable like JDK_HOME or JAVA_HOME, or is there a config file for the SunOne server somewhere ...

热门标签