Forum Discussion

sjy2025's avatar
sjy2025
Icon for Nimbostratus rankNimbostratus
Jul 22, 2025

iRule or Re-write Profile

I'm trying to work out how to do the following.

 

I have an irule that is directing source traffic (based on IP) to a specific pool

I have a rewrite policy > changing https://example.com to https://example.com/text

this is all working

 

The problem I have, is I'd like https://example.com to stay the same in the client's browser

But after the client connects to the backend servers, they return a uri https://host1.com

 

I'd like that to appear as https://example.com

 

I looked at my rewrite policy and was thinking I could do a response 

This doesn't appear to work.

Should I be using a single iRule to

Replace the name (inbound)

Direct to a pool

Replace the name (outbound)

2 Replies

  • Yes, you can try following rule.

    when HTTP_REQUEST {
        if { [IP::client_addr] eq "x.x.x.x" } {
            pool pool_A
        }
        HTTP::header replace "Host" "host1.com"
    }

    when HTTP_RESPONSE {
        if { [HTTP::header exists "Location"] } {
            set location [HTTP::header "Location"]
            set updated_location [string map {"host1.com" "example.com"} $location]
            HTTP::header replace "Location" $updated_location
        }

        # Optional: content replacement if backend returns HTML with embedded URLs
        if { [HTTP::header "Content-Type"] contains "text/html" } {
            STREAM::enable
        }
    }

    when STREAM_MATCHED {
        STREAM::replace "host1.com" "example.com"
    }

    when HTTP_RESPONSE_DATA {
        # Needed for stream profile
    }

    please try above irule.