change WebLogicHost or Location section based on cookie on oracle http server

338 Views Asked by At

I wanted to change WebLogicHost or the location section based on http-cookie on oracle http server 12.1.3

Below is the original working configuration in mod_wl_ohs.conf

<Location /base>
     SetHandler weblogic-handler
        WebLogicHost x.x.2.16
        WebLogicPort 5051
        DynamicServerList ON
        WLIOTimeoutSecs 3600
    WLSocketTimeoutSecs 750
    ConnectRetrySecs 2
    ConnectTimeoutSecs 10
 </Location>
DynamicServerList ON

For cookie based location change my changes are shown below,(mod_wl_ohs.conf)

RewriteEngine  on
#RewriteCond %{HTTP_COOKIE} LOC_Val=New-Loc [NC]
RewriteRule ^/base/(.*) /newbase/$1 [NC]

<Location /newbase>
     SetHandler weblogic-handler
        WebLogicHost x.x.2.50
        WebLogicPort 7071
        DynamicServerList ON
        WLIOTimeoutSecs 3600
    WLSocketTimeoutSecs 750
    ConnectRetrySecs 2
    ConnectTimeoutSecs 10
</Location>

<Location /base>
     SetHandler weblogic-handler
        WebLogicHost x.x.2.16
        WebLogicPort 5051
        DynamicServerList ON
        WLIOTimeoutSecs 3600
    WLSocketTimeoutSecs 750
    ConnectRetrySecs 2
    ConnectTimeoutSecs 10
 </Location>
DynamicServerList ON

Or cookie checking in the Location section(mod_wl_ohs.conf)

<Location /base>
  <If "%{HTTP_COOKIE} =~ /LOC_Val=New-Loc/">
     SetHandler weblogic-handler
        WebLogicHost x.x.2.50
        WebLogicPort 7071
        DynamicServerList ON
        WLIOTimeoutSecs 3600
    WLSocketTimeoutSecs 750
    ConnectRetrySecs 2
    ConnectTimeoutSecs 10
  </If>
  <Else>
     SetHandler weblogic-handler
        WebLogicHost x.x.2.16
        WebLogicPort 5051
        DynamicServerList ON
        WLIOTimeoutSecs 3600
    WLSocketTimeoutSecs 750
    ConnectRetrySecs 2
    ConnectTimeoutSecs 10
  </Else>
</Location>

In first option, requests go to 2.16 only. For testing purpose I tried commenting RewriteCond line, still url requests go to 2.16.

For second option server does not start. What is wrong?

How can I change the URL based on cookie value so that request will get forwarded to location section /newbase that is 2.50

0

There are 0 best solutions below