Forum Discussion
Pav_70755
Nimbostratus
Oct 20, 2010HTTP Re-Direct with html holding page
I have a standard HTTP re-direct in place and want to know how I can incorporate a HTML holding page before it re-directs.
11 Replies
- Chris_Miller
Altostratus
Give this a shot.when HTTP_REQUEST { if { [TCP::local_port] eq "80" } { persist source_addr 1800 HTTP::fallback http://support.com/ set dtime 3 Un-comment the next 3 lines for redirects and expand out with elseif's if needed if { [HTTP::host] == "www.domain.co.uk" or "www.domain.com" or "www.domain.org" } { HTTP::respond 200 content \ "Apology page\ We are sorry, but the site you are looking for is temporarily out of service." "Content-Type" "text/html" } else { pool Web_Farm_Front Un-comment the net line if using redirects } } elseif { [TCP::local_port] eq "443" } { HTTP::header insert "BPL-SSL" "On" pool Web_Farm_Front } else { set srvr [findclass [TCP::local_port] $::Individual_Servers " "] if { $srvr ne "" } { node $srvr 80 } else { Replace HTTP://sitename with the default URL of the site HTTP::redirect "http://www.domain.net/" } } }
I borrowed logic from the LTM Lite Maint Page.
http://devcentral.f5.com/wiki/default.aspx/iRules/LTMMaintenancePageLite.html
I haven't tested the above so wouldn't be surprised if it didn't need a tweek or 2. - Pav_70755
Nimbostratus
Hi Chris,
I tried to modify this rule to use a more complex holding page but was wondering if it was possible to use an existing asp page as the holding page rather than having to add the code to the i-rule?
here is what i have but im getting parsing errors.
Thanks
PavUn-comment the following lines if the site uses SSL when CLIENT_ACCEPTED { TCP::collect 5 } when CLIENT_DATA { if { [matchclass [TCP::payload] starts_with $::http_methods] } { SSL::disable } } when HTTP_REQUEST { if { [TCP::local_port] eq "80" } { persist source_addr 1800 HTTP::fallback http://support.com/ set dtime 3 Un-comment the next 3 lines for redirects and expand out with elseif's if needed if { [HTTP::uri] ends_with "/default.asp?File=pressdetail&id=87" } { HTTP::respond 200 content \ "JAN We've Moved! Temp holding page Temp You will automatically be redirected in 5 seconds. Alternatively, you can visit Temp now © Temp & , Inc. " } else { pool Web_Farm_Front Un-comment the net line if using redirects } } elseif { [TCP::local_port] eq "443" } { HTTP::header insert "BPL-SSL" "On" pool Web_Farm_Front } else { set srvr [findclass [TCP::local_port] $::Individual_Servers " "] if { $srvr ne "" } { node $srvr 80 } else { Replace HTTP://sitename with the default URL of the site HTTP::redirect "http://www.domain.net/" } } } - hoolio
Cirrostratus
... - hoolio
Cirrostratus
Hi Pav,
Can you try this?
You may need to edit this line if the forum code HTML encodes the ampersand:
if { [HTTP::uri] ends_with "/default.asp?File=pressdetail&id=87" } {when CLIENT_ACCEPTED { Start of HTML Save the HTML here with support for variables set html [subst -nocommands { JAN We've Moved! Temp holding page Temp You will automatically be redirected in 5 seconds. Alternatively, you can visit Temp now © Temp & , Inc. }] End of HTML } Un-comment the following lines if the site uses SSL when CLIENT_ACCEPTED priority 501 { TCP::collect 5 } when CLIENT_DATA { if { [matchclass [TCP::payload] starts_with $::http_methods] } { SSL::disable } } when HTTP_REQUEST { if { [TCP::local_port] == 80 } { persist source_addr 1800 HTTP::fallback http://support.com/ set dtime 3 Un-comment the next 3 lines for redirects and expand out with elseif's if needed if { [HTTP::uri] ends_with "/default.asp?File=pressdetail&id=87" } { HTTP::respond 200 content $html } else { pool Web_Farm_Front Un-comment the net line if using redirects } } elseif { [TCP::local_port] == "443" } { HTTP::header insert "BPL-SSL" "On" pool Web_Farm_Front } else { set srvr [findclass [TCP::local_port] $::Individual_Servers " "] if { $srvr ne "" } { node $srvr 80 } else { Replace HTTP://sitename with the default URL of the site HTTP::redirect "http://www.domain.net/" } } }
Aaron - Colin_Walker_12Historic F5 AccountYou won't be able to suck in an outside page, no. You'll need to put the HTML in either the iRule directly or you can put it into a data group, but that takes a little more massaging.
Colin - Pav_70755
Nimbostratus
Thanks Hollio that worked,
I've been asked to set up quite a few re-directs with holding pages but can the rule be modied to do multiple re-directs to different pages but all using the same holding page?
Thanks
Pav - Pav_70755
Nimbostratus
Also for some reason these re-directs dont seem to work in IE9 but work perfectly in firefox? are there any IE specific tags or entries that need to be made? - Pav_70755
Nimbostratus
OK i've realised that this is because I have changed the HTTP::respond 200 to HTTP::respond 301 is there any workaround for this?
Thanks
Pav - fLyf5_21542
Nimbostratus
First hit on the VS is on port 80 and team here doesnt want the request reaching webserver, the default page which they shared contain images, please advice on how to store these images locally and to display the page properly. - fLyf5_21542
Nimbostratus
Hi Pav
Thank you, this is what we are considering as a workaroud. However application team has a plan to stop directory browsing and hence we need to keep the image locally on the box. Is it possible to store the images under datagroup or in /var/tmp and refer the same in the html code.
Regards
fLy
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
