Redirect

So this is what I’m trying to do… We have a production webpage (virtual server/pool) with basic health monitors. We have a maintenance webpage (virtual server/pool). So the application guys want to be able to change the header on the maintenance webpage to contain the word “down” and when that happens they want the production webpage to redirect to the maintenance webpage. And flip back over when they remove the word “down.”

Any help would be much appreciated…

is the example irule in sol6510 applicable?

sol6510: BIG-IP system fallback host behavior when a host is down

No. They want to have the word “down” in the header (really meaning they made the maintenance page they want available) on the maintenance VS and when that maintenance page is available they want the production VS to redirect to that very maintenance page.

Appreciate the quick response.

e.g.

172.28.19.79 is production virtual

200.200.200.101 is production pool

172.28.19.89 is maintenance virtual

[root@ve10:Active] config  b virtual prod list
virtual prod {
   snat automap
   pool prodpool
   destination 172.28.19.79:80
   ip protocol 6
   rules myrule
   profiles {
      http {}
      tcp {}
   }
}
[root@ve10:Active] config  b pool prodpool list
pool prodpool {
   monitor all myhttp
   members 200.200.200.101:80 {}
}
[root@ve10:Active] config  b monitor myhttp list
monitor myhttp {
   defaults from http
   dest 172.28.19.89:80
   reverse
   recv "down"
   send "GET /test.html HTTP/1.1\r\nHost: \r\nConnection: Close\r\n\r\n"
}
[root@ve10:Active] config  b rule myrule list
rule myrule {
   when HTTP_REQUEST {
   if {[active_members [LB::server pool]] < 1} {
     HTTP::fallback "http://172.28.19.89"
   }
}
}

[root@ve10:Active] config  curl http://172.28.19.89/test.html
down

[root@ve10:Active] config  b pool prodpool|grep -i pool
POOL prodpool  LB METHOD round robin   MIN/CUR ACTIVE MEMBERS 0/0
+-> POOL MEMBER prodpool/200.200.200.101:80   inactive,down

[root@ve10:Active] config  curl -I http://172.28.19.79
HTTP/1.0 302 Found
Location: http://172.28.19.89
Connection: close

another way.

[root@ve10:Active] config  b virtual prod list
virtual prod {
   snat automap
   pool prodpool
   destination 172.28.19.79:80
   ip protocol 6
   rules myrule
   profiles {
      http {}
      tcp {}
   }
}
[root@ve10:Active] config  b rule myrule list
rule myrule {
   when HTTP_REQUEST {
   if {[LB::status pool foo member 172.28.19.89 80] eq "up"} {
      HTTP::redirect "http://172.28.19.89"
   }
}
}
[root@ve10:Active] config  b pool foo list
pool foo {
   monitor all myhttp
   members 172.28.19.89:80 {}
}
[root@ve10:Active] config  b monitor myhttp list
monitor myhttp {
   defaults from http
   dest 172.28.19.89:80
   recv "down"
   send "GET /test.html HTTP/1.1\r\nHost: \r\nConnection: Close\r\n\r\n"
}

[root@ve10:Active] config  curl http://172.28.19.89/test.html
down

[root@ve10:Active] config  b pool foo|grep -i pool
POOL foo  LB METHOD round robin   MIN/CUR ACTIVE MEMBERS 0/1
+-> POOL MEMBER foo/172.28.19.89:80   active,up

[root@ve10:Active] config  curl -I http://172.28.19.79
HTTP/1.0 302 Found
Location: http://172.28.19.89
Server: BigIP
Connection: Keep-Alive
Content-Length: 0

I’m not sure I fully comprehend your requirements. But how about this -

Apply a second monitor to the production pool which hits the maintenance pool members (using the Alias Address/Alias Service Port options if necessary), and leaving the Availability Requirement set to All. When the maintenance monitor goes down (by “changing the header”), that will trigger the LB_FAILED event on the production VIP. Then you can catch it with an iRule:

when LB_FAILED {

HTTP::redirect “http://(maintenance URL)”

}

That’s exactly what I tried to do. Having issues with getting their header. Are you sure that we can apply a health monitor to a Virtual server that then points to another site (is that what the alias does?) also what about persistance? I’m told that even if the members are down, persistant connections will still go to them.

The health monitor is applied to a Pool, not a Virtual Server. But yes, the Alias fields say, in effect, “check this ip address/port instead of the ip/port of the members in the pool where it’s applied”. But what I would do first is create a bogus pool with the maintenance members and apply the maintenance monitor there. That way, you’re not fussing with the production pool.

There could be a number of issues around “getting the header” (still not 100% confident I understand what that means exactly, but I think I do). One thing I know for certain is that the LTM only looks for the Receive String in the the first 5120 bytes of the HTTP response - the response headers are included in that 5120 limit. But assuming it’s not that or something like a firewall or routing issue, typically what I would do is perform a tcpdump and see exactly how the maintenance server is responding on the wire. This is something I do all the time, but not everyone knows how to do this or analyze the output. I can help if needed if you feel comfortable sharing a network trace. You may be able to send me a private message with attachment if you don’t want to post it to everyone.

(edit)

Also I forgot to answer your persistence question. I think when the Virtual Server is marked down, it will still trigger the LB_FAILED event even if the connection is persistent because when the VS is down, the LTM has nowhere to send the traffic. You should test this though.

That’s exactly what I tried to do. Having issues with getting their header.

Also, post what LTM version you are running and your maintenance monitor Send and Receive Strings - sanitize if necessary. It’s possible you arent using the correct CR/LF line-termination characters.

Everything with the redirect irule works. The problem is I cannot get the health monitor to work.

The app guys gave me this.

https://testmaint.xyz.com/getwebsit…x?env=test

If I go to this webpage with a Internet browser, it says “down” in the body.

So I created this for the send string

GET / HTTP/1.1\nHost: .xyz Domain Names | Join Generation XYZ\nConnection: close\n\n\r\n

and a receive string

down

-------

For alias address it just has this and I cannot change anything.

Alias Address * All Addresses

Alias Service Port * All Ports

_________

BIG-IP 10.2.3 Build 112.0 Final

GET / HTTP/1.1\nHost: .xyz Domain Names | Join Generation XYZ\nConnection: close\n\n\r\ncan you try this?

GET /getwebsitestatus.aspx?env=test HTTP/1.1\r\nHost: testmaint.xyz.com\r\nConnection: close\r\n\r\n

sol2167: Constructing HTTP requests for use with the HTTP or HTTPS application health monitor

by the way, it is https monitor, isn’t it?

For alias address it just has this and I cannot change anything.you have to create a new one i.e. you cannot change it after creating.

What would I put in the alias address anyway.The actual IP of the testmaint.xyz.com website?

What would I put in the alias address anyway.The actual IP of the testmaint.xyz.com website?yes and alias service port should be 443.

Thanks SMP and nitass,

I got it to work…

Smp when you came up with the same logic I was trying I knew I was on the right track. People I work with did not agree.

nitass thanks for the GET, i knew it was a problem and just didn’t know the correct syntax.

In the alias I put the IP address of the website and the port 443. The health monitor worked then i used reverse and lo and behold it did what i wanted.

THANKS AGAIN!!!

You are welcome. However, I was thinking through my recommendation a bit, and there might be an implication you should be aware of depending on how you have it configured. Do you have two monitors on the pool, or just the maintenance monitor? If you have two monitors on the pool and are using the iRule I suggested, then if EITHER monitor fails you will get redirected to the maintenance page - not just when the maintenance monitor fails. That may not be the behavior you want. If you only apply the maintenance monitor, then it’s not an issue. But if you want different behavior depending on which monitor fails, then we might need to come up with something else.

SMP you read my mind, my plan was to alter the irule. Strange that we think alike, kinda scary. I’m not a TCL guy, I’m a network guy and I get the logic but I don’t know the code. So here is the deal

I have two health monitors

Health1

Health2

Here is my irule.

when LB_FAILED {

HTTP::fallback “.xyz Domain Names | Join Generation XYZ”

}

There has got to be a way to include Health2 as being down as a criteria for when to fallback within the irule.

I’m hoping you or Nitass can assist. Judging by Nitass’s input he knows TCL like the back of his hand.

what about if using only health1 on production pool, health2 on maintenance pool and then in production irule, using “LB::status pool” command to see if maintenance pool is up or down and redirect accordingly?

just my 2 cents.

So if I created another pool without a VS and called it “health_pool” (i can use the same IPs of the maintenance page pool) then use that special monitor I created to get the website “down” message which would take down the health_pool. Then, i could go to the prod pool and put in an irule. Can i reference a pool that is not the same pool as where I’m applying the irule? So what would that Irule look like under the prod pool?

when LB_FAILED {

if { [LB::status pool health_pool] eq down}{

HTTP::fallback “.xyz Domain Names | Join Generation XYZ”

Can i reference a pool that is not the same pool as where I’m applying the irule? So what would that Irule look like under the prod pool? yes but i understand you also have to specify pool member.

e.g.

LB::status pool (name) member (ip) (port)

LB::status wiki

and you should use HTTP_REQUEST event instead of LB_FAILED since on production, it does not fail.

Something like this.

when HTTP_REQUEST {

if { [LB::status pool health1 member x.x.x.x 443] eq down}{

HTTP::fallback “.xyz Domain Names | Join Generation XYZ”

}

}

or like this

when HTTP_REQUEST {

if { [LB::status pool health1 member x.x.x.x 443] eq down}{

HTTP::redirect “.xyz Domain Names | Join Generation XYZ”

}

}

The only problem I worry about is with persistance. Which will happen. When I did it the other way persistance caused a problem but since I had a health monitor I was able to force a reset when the pool went down and then redirect to the new page. I won’t have that option this way. Unless I can include something in this irule.