Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Forwarding request to html file when file exists on IBM HTTP Server (with dynamicRouting enabled)

I have a configuration where I’m rewriting request to a %{DOCUMENT_ROOT}/break/break_on.html when %{DOCUMENT_ROOT}/break/break_on.enable file exists.
Look at CONDITION NR1

DocumentRoot /opt/IBM/HTTPServer/htdocs
RewriteEngine On

# CONDITION NR1
RewriteCond %{DOCUMENT_ROOT}/break/break_on.html -f
RewriteCond %{DOCUMENT_ROOT}/break/break_on.enable -f
RewriteCond %{SCRIPT_FILENAME} !break/break_on.html
RewriteRule (.*) /break/break_on.html [PT,L]

This was always working with traditional WebSphere. Now since I have WebSphere Liberty with dynamicRouting enabled, the dynamicRouting is sending a request to WebSphere Liberty Servers instead of rediricting it to local %{DOCUMENT_ROOT}/break/break_on.html

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Status line for URI [/break/break_on.html] client port [60960] transport [libertyController:9080]: HTTP/1.1 404 Not Found
[11/Feb/2023:16:49:47.46640] 00013a65 30115700 – ODR:DEBUG: Reading response headers for URI [/break/break_on.html] client port [60960] transport [libertyController:9080]:

Look at http_plugin.log:

[11/Feb/2023:16:49:47.46208] 00013a65 30094700 - ODR:INFO: http.summary: [0x7f8604008920] RESPONSE_SENT Initial 20.45.100.115 GET HTTP/1.1 http://break/break_on.html?v=2 libertyNode:9080 0 404 5ms 9ms
[11/Feb/2023:16:49:47.46209] 00013a65 30094700 - ODR:DEBUG: odrHttpContextSetStateInternal: exit
[11/Feb/2023:16:49:47.46210] 00013a65 30094700 - ODR:DEBUG: odrHttpContextRelease: deleting proxy=0x7f8604008bb0 delegate=0x7f8604008920
[11/Feb/2023:16:49:47.46211] 00013a65 30094700 - ODR:DEBUG: odrHttpContextRelease: enter - ctx=0x7f8604008920
[11/Feb/2023:16:49:47.46212] 00013a65 30094700 - ODR:DEBUG: odrHttpContextClean: enter - ctx=0x7f8604008920
[11/Feb/2023:16:49:47.46213] 00013a65 30094700 - ODR:DEBUG: odrTargetSelector.tsLockObtain: ts=0x7f8624000c40 obtained lock=0x7f8624000cf0 (heldBy=NOBODY) for tsTargetInfoDecrementRefCnt
[11/Feb/2023:16:49:47.46214] 00013a65 30094700 - ODR:DEBUG: odrTargetSelector.tsTargetinfoDecrementRefCnt: sapp 0x7f862415ef50, tep 2, server 2, node 2, cluster 5, cell 3
[11/Feb/2023:16:49:47.46215] 00013a65 30094700 - ODR:DEBUG: odrTargetSelector.endPointDelete: Releasing reference to endpoint /cell/defaultCollective/node/libertyNode,%2Fapp%2FIBM%2FLiberty%2Fusr/server/srv_libertyApp_1/transport/Http; refcnt=2
[11/Feb/2023:16:49:47.46216] 00013a65 30094700 - ODR:DEBUG: odrTargetSelector.serverDelete: release /cell/defaultCollective/node/libertyNode,%2Fapp%2FIBM%2FLiberty%2Fusr/server/srv_libertyApp_1 (refcnt=1)
[11/Feb/2023:16:49:47.46218] 00013a65 30094700 - ODR:DEBUG: odrTargetSelector.nodeDelete: node 0x7f86241014a0: release /cell/defaultCollective/node/libertyNode,%2Fapp%2FIBM%2FLiberty%2Fusr (refcnt=1)
[11/Feb/2023:16:49:47.46219] 00013a65 30094700 - ODR:DEBUG: odrTargetSelector.cellDelete: cell 0x7f862406bb70: release /cell/defaultCollective (refcnt=2)
[11/Feb/2023:16:49:47.46220] 00013a65 30094700 - ODR:DEBUG: odrTargetSelector.tsLockRelease: ts=0x7f8624000c40 released lock=0x7f8624000cf0 (heldBy=tsTargetInfoDecrementRefCnt)
[11/Feb/2023:16:49:47.46221] 00013a65 30094700 - ODR:DEBUG: odrHttpContextClean: exit
[11/Feb/2023:16:49:47.46222] 00013a65 30094700 - ODR:DEBUG: odrHttpContextSetStateInternal: enter - ctx=0x7f8604008920, state=CACHED, url=
[11/Feb/2023:16:49:47.46223] 00013a65 30094700 - ODR:DEBUG: odrHttpContextSetStateInternal: exit
[11/Feb/2023:16:49:47.46223] 00013a65 30094700 - ODR:DEBUG: odrRoutingInfoRelease: enter - ri=0x7f86240008e0
[11/Feb/2023:16:49:47.46224] 00013a65 30094700 - ODR:DEBUG: odrRoutingInfoRelease: refCount=2, ri=0x7f86240008e0
[11/Feb/2023:16:49:47.46225] 00013a65 30094700 - ODR:DEBUG: odrRoutingInfoRelease: exit
[11/Feb/2023:16:49:47.46226] 00013a65 30094700 - ODR:DEBUG: odrHttpContextRelease: exit
[11/Feb/2023:16:49:47.46637] 00013a65 30115700 - ODR:DEBUG: Status line for URI [/break/break_on.html] client port [60960] transport [libertyController:9080]:   HTTP/1.1 404 Not Found
[11/Feb/2023:16:49:47.46640] 00013a65 30115700 - ODR:DEBUG: Reading response headers for URI [/break/break_on.html] client port [60960] transport [libertyController:9080]:
[11/Feb/2023:16:49:47.46641] 00013a65 30115700 - ODR:DEBUG:    X-Powered-By: Servlet/3.1
[11/Feb/2023:16:49:47.46642] 00013a65 30115700 - ODR:DEBUG:    Content-Type: text/html
[11/Feb/2023:16:49:47.46643] 00013a65 30115700 - ODR:DEBUG:    $WSEP:
[11/Feb/2023:16:49:47.46644] 00013a65 30115700 - ODR:DEBUG:    Date: Sat, 11 Feb 2023 15:49:47 GMT
[11/Feb/2023:16:49:47.46645] 00013a65 30115700 - ODR:DEBUG:    Last-Modified: Wed, 04 Jan 2023 14:12:12 GMT
[11/Feb/2023:16:49:47.46646] 00013a65 30115700 - ODR:DEBUG:    Content-Length: 2109
[11/Feb/2023:16:49:47.46647] 00013a65 30115700 - ODR:DEBUG:    Content-Language: en-US
[11/Feb/2023:16:49:47.46648] 00013a65 30115700 - ODR:DEBUG:    Connection: Close
[11/Feb/2023:16:49:47.46649] 00013a65 30115700 - ODR:DEBUG: odrHttpContextSetStateInternal: enter - ctx=0x7f86140028f0, state=RESPONSE_ARRIVED, url=
[11/Feb/2023:16:49:47.46650] 00013a65 30115700 - ODR:DEBUG: odrHttpContextPerformResponseProcessing: wsptHdr=null, partitionVerHdr=null
[11/Feb/2023:16:49:47.46651] 00013a65 30115700 - ODR:DEBUG: getResponseSessionCookie: Checking if session cookie JSESSIONID is present in the response
[11/Feb/2023:16:49:47.46652] 00013a65 30115700 - ODR:DEBUG: getResponseSessionCookie: No session cookie found in the response
[11/Feb/2023:16:49:47.46653] 00013a65 30115700 - ODR:DEBUG: getCookieValue: cookieHeaderValue=null
[11/Feb/2023:16:49:47.46653] 00013a65 30115700 - ODR:DEBUG: getRequestSessionCookieValue: Checking if session cookie JSESSIONID is present in the request
[11/Feb/2023:16:49:47.46655] 00013a65 30115700 - ODR:DEBUG: getRequestSessionCookieValue: No session cookie found in the request
[11/Feb/2023:16:49:47.46656] 00013a65 30115700 - ODR:DEBUG: odrTargetSelector.tsLockObtain: ts=0x7f8624000c40 obtained lock=0x7f8624000cf0 (heldBy=NOBODY) for tsServerApplicationDecrementOutstandingRequestCount
[11/Feb/2023:16:49:47.46657] 00013a65 30115700 - ODR:DEBUG: hmCheckHealthPolicies: Server='/cell/defaultCollective/node/libertyController,%2Fapp%2FIBM%2FLiberty%2Fusr/server/srv_libertyApp_2' avgRT=10 timeoutPct=0
[11/Feb/2023:16:49:47.46658] 00013a65 30115700 - ODR:DEBUG: odrTargetSelector.tsLockRelease: ts=0x7f8624000c40 released lock=0x7f8624000cf0 (heldBy=tsServerApplicationDecrementOutstandingRequestCount)
[11/Feb/2023:16:49:47.46659] 00013a65 30115700 - ODR:DEBUG: odrHttpContextSetStateInternal: exit
[11/Feb/2023:16:49:47.46665] 00013a65 30115700 - ODR:DEBUG: odrHttpContextSetStateInternal: enter - ctx=0x7f86140028f0, state=RESPONSE_SENT, url=

So it’s obvious that I get 404, this resource doesn’t exist on libertyNode, it exists where I have IBM HTTP Server installed.

How can I make sure, that all request are going to %{DOCUMENT_ROOT}/break/break_on.html when %{DOCUMENT_ROOT}/break/break_on.enable file exist on localhost instead of going to WebSphere Liberty Controller?

Thanks!

>Solution :

Since the URL shares a context root with a deployed application, you’ll have to get the websphere plugin to decline handling it and let it defer to the default static file handler (very low priority):

The skipwas environment variable is the flexible way to handle this:

   RewriteRule (.*) /break/break_on.html [PT,L,E=skipwas:1]

I don’t think there’s a tWAS vs Liberty difference here, or even dynamic routing. I think you were mapping your applications differently (or inadvertently have an application mapped to /)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading