Forum Discussion

dp_119903's avatar
dp_119903
Icon for Cirrostratus rankCirrostratus
Feb 13, 2017

Need a redirect and a stream profile

I am trying to do something that I think is pretty simple. Strangely enough I have what I'm trying to do working just fine on one F5, but the behavior isn't replicating when I move it to another F5. I suspect it has something to do with sequencing.

This is what I need to do.

I have two Virtual Servers. Both are listening on 443.

Virtual Server 1 has backend servers listening on port 80. Virtual Server 2 has backend servers listening on port 10108.

  1. My first requirement is that when users go to virtual server 1 with a blank URI that they get redirected to /gohere. I do that with an irule:


when HTTP_REQUEST {
   if {[HTTP::path] eq "/"}{
      HTTP::redirect https://[HTTP::host]/gohere }
}

...and that works just fine.

Now, when the user is logged into virtual server 1 they run a report that essentially provides them a link that tells is to go to virtual server 2. B/c virtual server 2 is listening (the actual servers) on 10108 it sends the URL as .

I want to take that response and change it to:

...at first I just added an empty stream profile and the irule that Kevin Steward created,


when HTTP_REQUEST {
     tell server not to compress response
    HTTP::header remove Accept-Encoding

     disable STREAM for request flow
    STREAM::disable
}
when HTTP_RESPONSE {
     catch and replace redirect headers
    if { [HTTP::header exists Location] } {
        HTTP::header replace Location [string map {"http://" "https://"} [HTTP::header Location]]
    }

     only look at text data
    if { [HTTP::header Content-Type] contains "text" } {

         create a STREAM expression to replace any http:// with https://
        STREAM::expression {@http://@https://@}

         enable STREAM
        STREAM::enable
    }
}

and it started working just fine. However, now when I tried to build that same environment in production it's not working.

With both irules applied I get nothing.

When I remove the stream profile and the stream irule I get redirected correctly.

However when I put the stream profile back on and add the irule it breaks again.

For troubleshooting I tried to put both irules into one irule (combining them). That worked...initially, but then stopped working. I have tried to use the priority command to put a priority of 100 on the redirect irule and left the stream at default (500)...but that doesn't work either.

I feel like this should be fairly simple, I can't figure out why it works in my test environment but not in production. Any assistance would be appreciated.

  • If your iRule is working fine on one F5 Environment and it isn't working on other, then I do not see any issues with iRule. This leads me to verify the virtual server configuration and the backend server who are handling these requests. You can compare working and non-working setup with respect to vServers settings and backend server's configuration. 

     

    Please also verify if your working and non-working F5 instances are on different versions.