Redirector Problem

Hello everybody:

I´m trying to forward http requests to one or other Web server depending on the http header.

Example.

http://VirtualServer/magallanes --> Should go to Magallanes HOst

http://VirtualServer/hansolo --> Should go to Hansolo host

SO i have created a VS (stardard mode) with SNAT automode. and two pools one with each server.

I have added this IRule

when HTTP_REQUEST {

if { [HTTP::uri] starts_with “/magallanes” } {

pool pool_magallanes

}

elseif { [HTTP::uri] starts_with “/hansolo” } {

pool pool_hansolo

}

}

But it doesn´t works, i get a message in my browser that the page cannot be displayed

Thanks in advance

Nacho

Try adding some logging:

log "Host is [HTTP::host], URI is [HTTP::uri]"
when HTTP_REQUEST {
   if { [HTTP::uri] starts_with "/magallanes" } {
   log "IF successful on URI [HTTP::uri]"
   pool pool_magallanes
   } elseif { [HTTP::uri] starts_with "/hansolo" } {
      log "ELSEIF successful on URI [HTTP::uri]"
      pool pool_hansolo
   } 
}

Excuse me, but i´m new with BigIP

Should i put this text in the Irule?

Where is going to write the log file?

Thanks

You can create what I posted as a new rule, or you can update your rule, either way will work. The log command by default logs to /var/log/ltm.

log “Host is [HTTP::host], URI is [HTTP::uri]”

This first line gives me this error in the IRule editor

01070151:3: Rule [logfile] error:

line 1: [command is not valid in the current scope] [log “Host is [HTTP::host], URI is [HTTP::uri]”]

line 1: [command is not valid in the current scope] [HTTP::host]

line 1: [command is not valid in the current scope] [HTTP::uri]

If i remove it i can update the irule,

Yeah, my bad on that. The first log line should go immediately after the when HTTP_REQUEST, but before your if statement.

So the rule is doing what it should based on your log information, so the question is, does /magallanes exist on the 150.200.200.4 server, or should the URI be stripped off?

Nov 8 17:34:31 tmm tmm[714]: 01220002:6: Rule logfile : Host is 150.200.200.4, URI is /magallanes

Nov 8 17:34:31 tmm tmm[714]: 01220002:6: Rule logfile : IF successful on URI /magallanes

This the result after modify the iRule

This means the Irule is working fine?

Is the problem in my VS?

Thanks

There isn’t a problem with the rule or the vip that I can see, check your 10.200.200.4 server to see if /magallanes is a valid directory in your httpd.conf file. I’m guessing you really want to strip the URI once it has been used to determine the server. Try this:

when HTTP_REQUEST {
   log "Host is [HTTP::host], URI is [HTTP::uri]"
   if { [HTTP::uri] starts_with "/magallanes" } {
   log "IF successful on URI [HTTP::uri]"
   HTTP::uri "/"
   pool pool_magallanes
   } elseif { [HTTP::uri] starts_with "/hansolo" } {
      log "ELSEIF successful on URI [HTTP::uri]"
      HTTP::uri "/"
      pool pool_hansolo
   }
 }

Nov 8 17:59:30 tmm tmm[714]: 01220002:6: Rule logfile2 : Host is 150.200.200.4, URI is /magallanes

Nov 8 17:59:30 tmm tmm[714]: 01220002:6: Rule logfile2 : IF successful on URI /magallanes

The same as before, and the browser still saying there is no pages, although , the nodes lights are in green, also the pools and the VS

Have you checked your server? Add this to your rule:

when HTTP_RESPONSE {

log “HTTP Status code is [HTTP::status]”

}

There is no entries in the log file refering anything about the irule that says:

when HTTP_RESPONSE {

log “HTTP Status code is [HTTP::status]”

}