iRule to redirect URI based on host using Datagroup
I'm experiencing a strange looping condition while testing an iRule to match host to redirect to a specific URI in a datagroup. I'm uncertain if this is a web server configuration or something in the iRule?
Host Host + URI
cc.site1.com = cc.site1.com/cc1/
FYI: The final URI will look something like /cc/cc?site=abc123
DG:
ltm data-group internal CC-Host-to-URI-Redirect-DG {
records {
data /cc/
}
data /cc1/
}
}
type string
}
iRule
when HTTP_REQUEST {
if { [ class match [HTTP::host] equals CC-Host-to-URI-Redirect-DG ] } {
set new_URI [ class match -value [HTTP::host] equals CC-Host-to-URI-Redirect-DG ]
HTTP::redirect "https://[getfield [HTTP::host] ":" 1]$new_URI
}
}
cURL
Note: Output limited
# curl -vik --resolve cc.site.com:443:10.10.10.18 https://cc.site.com
> GET / HTTP/1.1
> Host: cc.site.com
> User-Agent: curl/7.47.1
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 301 Moved Permanently
HTTP/1.0 301 Moved Permanently
< new: server
new: server
< location: https://cc.site.com/cc/
location: https://cc.site.com/cc/
< Server: BigIP
Server: BigIP
* HTTP/1.0 connection set to keep alive!
< Connection: Keep-Alive
Connection: Keep-Alive
< Content-Length: 0
Content-Length: 0
The response from cURL looks fine; however in a browser this loops until Chrome gives up then throws it back to the main page again and loops again.
/jeff