ProxyPass 10.5 URI rewrite failing

I am using LTM 10.2. I am attempting to use the ProxyPass 10.5 iRule located at DevCentral - An F5 Technical Community. I am setting up a staging test environment for multiple websites on IIS 7.5. I only have one external IP to use and one SSL cert with the associated domain name (staging.externaldomain.com). I have IIS setup to use host headers (staging.realdomainname.com). I have the ProxyPass setup to map the sites the following way:

staging.externaldomain.com/realdomainname := staging.realdomainname.com

When I attempt to browse the site everything appears to work until I attempt to login, I get a 404 "The resource cannot be found.

The log on the F5 is:

Thu Oct 11 13:30:20 MST 2012 info local/tmm tmm[5347] Rule proxypass_irule : VS=Staging_https_virtual_server, Host=staging.externaldomain.com, URI=/realdomainname/welcome.aspx: Changing response header Location: /welcome.aspx?id=WEBTEST with /welcome.aspx?id=WEBTESTstaging.externaldomain.com/realdomainname

The URL I get back in the browser is staging.externaldomain.com/welcome.aspx?id=WEBTESTstaging.externaldomain.com/realdomainname

If I modify the returned URL to staging.externaldomain.com/realdomainname/welcome.aspx?id=WEBTEST I get a logged in page and can continue to use the site with no issues.

I have attempted to change the set static::RewriteResponsePayload. I have used 0, 1, and 2 with no change. Enabling and disabling the streamprofile also does not change this behavior.

Any help figguring this out would be appreciated.

Adam

I enabled some additional logging.

Fri Oct 12 08:57:56 MST 2012 info local/tmm1 tmm1[5348] Rule proxypass_irule : VS=Staging_https_virtual_server, Host=staging.externaldomain.com, URI=/realdomainname/images/login.png: Found Rule, Client Host=staging.externaldomain.com, Client Path=/realdomainname, Server Host=staging.realdomainname.com, Server Path=

Fri Oct 12 08:57:56 MST 2012 info local/tmm1 tmm1[5348] Rule proxypass_irule : VS=Staging_https_virtual_server, Host=staging.externaldomain.com, URI=/realdomainname/images/login.png: Using default pool Staging_pool

Fri Oct 12 08:57:56 MST 2012 info local/tmm1 tmm1[5348] Rule proxypass_irule : VS=Staging_https_virtual_server, Host=staging.externaldomain.com, URI=/realdomainname/images/login.png: New Host=staging.realdomainname.com, New Path=/images/login.png

Fri Oct 12 08:57:56 MST 2012 info local/tmm1 tmm1[5348] Rule proxypass_irule : VS=Staging_https_virtual_server, Host=staging.externaldomain.com, URI=/realdomainname/images/login.png: Changing Referer header: https://staging.externaldomain.com/realdomainname/welcome.aspx to https://staging.realdomainname.com/welcome.aspx

Fri Oct 12 08:57:56 MST 2012 info local/tmm1 tmm1[5348] Rule proxypass_irule : VS=Staging_https_virtual_server, Host=staging.externaldomain.com, URI=/realdomainname/images/login.png: $stream_expression_cmd: STREAM::expression “@staging.realdomainname.com@staging.externaldomain.com/realdomainname@ @@/realdomainname@”, $stream_enable_cmd: STREAM::enable

Fri Oct 12 08:57:56 MST 2012 info local/tmm1 tmm1[5348] Rule proxypass_irule : VS=Staging_https_virtual_server, Host=staging.externaldomain.com, URI=/realdomainname/images/login.png: Successfully configured and enabled stream filter

Fri Oct 12 08:57:58 MST 2012 info local/tmm tmm[5347] Rule proxypass_irule : VS=Staging_https_virtual_server, Host=staging.externaldomain.com, URI=/realdomainname/welcome.aspx: $stream_expression_cmd: STREAM::expression “@staging.realdomainname.com@staging.externaldomain.com/realdomainname@ @@/realdomainname@”, $stream_enable_cmd: STREAM::enable

Fri Oct 12 08:57:58 MST 2012 info local/tmm tmm[5347] Rule proxypass_irule : VS=Staging_https_virtual_server, Host=staging.externaldomain.com, URI=/realdomainname/welcome.aspx: Successfully configured and enabled stream filter

Fri Oct 12 08:57:58 MST 2012 info local/tmm tmm[5347] Rule proxypass_irule : VS=Staging_https_virtual_server, Host=staging.externaldomain.com, URI=/realdomainname/welcome.aspx: Changing response header Location: /welcome.aspx?id=WEBTEST with /welcome.aspx?id=WEBTESTstaging.externaldomain.com/realdomainname

Fri Oct 12 08:57:58 MST 2012 info local/tmm tmm[5347] Rule proxypass_irule : Modifying cookie ASP.NET_SessionId path from / to /realdomainname/

Fri Oct 12 08:57:58 MST 2012 info local/tmm tmm[5347] Rule proxypass_irule : Inserting cookie: ASP.NET_SessionId=dx5rg355bjbqzbytcz4hqx45; path=/realdomainname/; HttpOnly

Fri Oct 12 08:57:58 MST 2012 info local/tmm1 tmm1[5348] Rule proxypass_irule : VS=Staging_https_virtual_server, Host=staging.externaldomain.com, URI=/welcome.aspx?id=WEBTESTstaging.externaldomain.com/realdomainname: No rule found

Fri Oct 12 08:57:58 MST 2012 info local/tmm1 tmm1[5348] Rule proxypass_irule : VS=Staging_https_virtual_server, Host=staging.externaldomain.com, URI=/welcome.aspx?id=WEBTESTstaging.externaldomain.com/realdomainname: Rewriting response content enabled, but disabled on this response.

Thanks,

Adam

Hi Adam,

Can you edit your post or post again with the logs in [ code ] [/ code ] blocks (without the spaces) to preserve the event names in the log entries?

Thanks, Aaron

Nevermind, this looks like a bug in this section of the iRule:

383    Fix Location, Content-Location, and URI headers
384   foreach header {"Location" "Content-Location" "URI"} {
385      set protocol [substr [HTTP::header $header] 0 $host_serverside]
386      if {$protocol ne ""} {
387         set server_path [findstr [HTTP::header $header] $host_serverside [string length $host_serverside]]
388         if {$server_path starts_with $path_serverside} {
389            if { $static::ProxyPassDebug } {
390               log local0. "$log_prefix: Changing response header $header: [HTTP::header $header] with $protocol$host_clientside$path_clientside[substr $server_path [string length $path_serverside]]"
391            }
392            HTTP::header replace $header $protocol$host_clientside$path_clientside[substr $server_path [string length $path_serverside]]
393         }
394      }
395   }

I’ll see if there’s a simple fix we can add to the general iRule. Else, maybe we can tailor something your your implementation.

Aaron

Hoolio-

Your 10.6 version fixed one of the issues I had with the iRule. Thanks a bunch.

I now am trying to fuggure out a way around the last issue I have. Our devs use a 302 redirect after page submission on a number of pages in the site. They only send back ‘/welcome.aspx?id=WEBTEST’ or similar which bypasses the iRule re-write because the URL portion does not get included. This truncates the URL and URI on the client side to staging.externaldomain.com/welcome.aspx?id=WEBTEST instead of staging.externaldomain.com/internaldomain/welcome.aspx?id=WEBTEST.

Does anyone have any ideas on a way around this?

Thanks again for your help.

Adam