Forum Discussion

JohnL_247646's avatar
JohnL_247646
Icon for Nimbostratus rankNimbostratus
Apr 13, 2016

ACE action-list header rewrite question

I am migrating from ACE to F5. There are a few action-list header rewrite in ACE that I don't know how to convert to F5 equivalent. Basically, the rewrite will change the FQDN from 1 host to another.

 

Here is the ACE command.

 

action-list type modify http MYACCOUNT header rewrite request Host header-value "myaccount[.]ABCXYZ[.]com(.*)" replace "services.ABCXYZ.com:50300%1" header rewrite response Location header-value "[.]ABCXYZ[.]com:50300/public/index[.]jsp" replace "https://myaccount.ABCXYZ.com/public/index.jsp"

 

The first header rewrite does a wildcard match for everything after myaccount.ABCXYZ.com and assign it to a 'variable' and appends to services.ABCXYZ.com:503000. I have some other rewrites that are not port specific. The challenge is keeping the rest of the URL request and not losing the strings after .com

 

So for example, if we have myaccount.ABCXYZ.com/testing/1234/test.jsp then the rewrite will change the url to services.ABCXYZ.com:50300/testing/1234/test.jsp.

 

I have been looking around and all I can find are irules to replace the host and drops everything after .com or http to https rewrites.

 

Does anyone know I can accomplish this?

 

Thanks in advance.

 

1 Reply

  • Hi John, I had the same issue not to long ago and thought i have put the code snippet on DevCentral so just added:

     

    HTTP to HTTPS Redirect Rewrite plus port change

     

    For your second example where you trying to remove port form the location header change the following line to remove the ':8443'

     

    lreplace $loc_list 2 2 '[lindex [split [lindex $loc_list 2] ":"] 0]:8443'

    e.g. Change to

     

    lreplace $loc_list 2 2 '[lindex [split [lindex $loc_list 2] ":"] 0]'

    Hope this helps