28-Aug-2016 10:57
i have the following code for a response:
' '
i am trying to rewrite (via irule, stream) the ip address (xxx.xxx.xxx.xxx) to a FQDN host name url.
my normal http_response irule does not pick up these strings when they are in an Head/Meta tag on response.
is there an irule code that picks this up and changes it.
thanks
28-Aug-2016
11:27
- last edited on
19-Dec-2022
15:31
by
JRahm
Hi Jim,
you may take a look to the STREAM code example below...
when HTTP_REQUEST {
Disable STREAM for HTTP_REQUESTs
STREAM::disable
Remove the "Accept-Encoding" header to see cleartext data on the responses.
Note: You could also use a HTTP-Compression Profile to remove the
Accept-Encoding header on the server side
(Profile Option: Keep Accept Encoding = Disabled).
By doing this, you can STREAM the content without losing
the ability to support a client side compression.
HTTP::header remove "Accept-Encoding"
}
when HTTP_RESPONSE {
Rechunk any Chunked Responses to become able to STREAM those content, without braking the Application.
if {[HTTP::header exists "Transfer-Encoding"]} {
HTTP::payload rechunk
}
Apply STREAM expression just to Content-Type = text
if {[HTTP::header value "Content-Type"] contains "text"}{
Set the STREAM expression
STREAM::expression {@https://1.1.1.1/@https://host.domain.tld/@}
Enable STREAM of the current response
STREAM::enable
}
}
Note: If this code does not translate the string https://1.1.1.1/ to https://host.domain.tld/, then you may take a look to the response headers and the HTML content and post them here. It could be either that the "Content-Type" value is different or that the tag is somehow URL encoded..
Cheers, Kai
29-Aug-2016 16:24
still cannot get this to rewrite. if the ip address is in the body of page, then it works. it does not work when it is in the part of oage.
my headers in response are: = PLPARrsp Client Response start --------------------------------- 2016-08-29 18:08:58Local7.Debug192.168.xxx.xxxtmm[22492]: Client xxx.xxx.xxx.xxx:65259 -> (response) 2016-08-29 18:08:58Local7.Debug192.168.xxx.xxxtmm[22492]: Server: IBM HTTP Server/V5R3M0 2016-08-29 18:08:58Local7.Debug192.168.xxx.xxxtmm[22492]: Date: Mon, 29 Aug 2016 23:09:08 GMT 2016-08-29 18:08:58Local7.Debug192.168.xxx.xxxtmm[22492]: Connection: Keep-Alive 2016-08-29 18:08:58Local7.Debug192.168.xxx.xxxtmm[22492]: Accept-Ranges: bytes 2016-08-29 18:08:58Local7.Debug192.168.xxx.xxxtmm[22492]: Content-Type: text/html 2016-08-29 18:08:58Local7.Debug192.168.xxx.xxxtmm[22492]: Last-Modified: Fri, 26 Aug 2016 01:22:16 GMT
my page that has the ip address that I want to rewrite is:
hi from jim
30-Aug-2016
03:19
- last edited on
19-Dec-2022
15:34
by
JRahm
Hi Jim,
it doesn't matter where the tag is placed, since STREAM doesn't understand HTML at all. It just sees the flying by bits and bytes an then applies a replacements if a given search pattern is found.
Just combinaed my provided iRule logic with your provided HTML using the iRule below...
when HTTP_REQUEST {
Disable STREAM for HTTP_REQUESTs
STREAM::disable
Remove the "Accept-Encoding" header to see cleartext data on the responses.
Note: You could also use a HTTP-Compression Profile to remove the
Accept-Encoding header on the server side
(Profile Option: Keep Accept Encoding = Disabled).
By doing this, you can STREAM the content without losing
the ability to support a client side compression.
HTTP::header remove "Accept-Encoding"
if { [HTTP::path] eq "/stream" } then {
set content {
hi from jim
}
HTTP::respond 200 content $content "Content-Type" "text/html"
} else {
HTTP::path "/stream"
virtual [virtual]
}
}
when HTTP_RESPONSE {
Rechunk any Chunked Responses to become able to STREAM those content, without braking the Application.
if {[HTTP::header exists "Transfer-Encoding"]} {
HTTP::payload rechunk
}
Apply STREAM expression just to Content-Type = text
if {[HTTP::header value "Content-Type"] contains "text"}{
Set the STREAM expression
STREAM::expression {@https://1.1.1.1@https://www.site.de@}
Enable STREAM of the current response
STREAM::enable
}
}
Output:
hi from jim
Cheers, Kai
26-Nov-2022 10:32
To use a META Tag to redirect your site is quite easy. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute. The following is an example of redirecting current page to another page after 2 seconds.
27-Nov-2022 09:04 - edited 27-Nov-2022 10:05
09-Dec-2022 07:30 - edited 09-Dec-2022 07:37
It's simple to redirect your site using a meta tags. In order to do this, utilise the http-equiv attribute to supply an HTTP header with the content attribute's value. The next example shows how to switch to a different page after two seconds on the webpage meta tags analyzer.