Forum Discussion

vrn_159121's avatar
vrn_159121
Icon for Altostratus rankAltostratus
Sep 23, 2017

how to handle internal server redirects 301 & 302 which redirect to another ports

Hi below is my config backend node is with port 80 and VS is 443 doing ssl offload

 

Problem once i browse https://xyz.com my internal server gives a response 301 and redirects to another url ie: http://xyz.com/hop ---- no problem here as i have enable redirect rewrite all.

 

after https://xyz.com/com/hop again the interal server gives a response 302 and redirects to http://xyz.com:4444/form ---- problem here - how to handle this ?

 

i have only create node with port 80 i dont want client to see the url with port 4444 it should be always https://xyz.com/...

 

do i need a irule or do i need to create node with 4444

 

1 Reply

  • Hi VRN,

    Could you try the following irule

        when HTTP_REQUEST {
    
      Remove the "Accept-Encoding" header 
     HTTP::header remove "Accept-Encoding"
    
      Disable the stream filter for all requests 
     STREAM::disable 
    
    } 
    
    when HTTP_RESPONSE {
    
        if {[HTTP::header exists Location] } {
            log local0. "Old Location is: [HTTP::header Location]"
            HTTP::header replace Location [string map {"xyz.com:4444" "xyz.com"} [HTTP::header Location]]
            log local0. "New Location is: [HTTP::header Location]"
        }
    
         Check if response type is text 
        if { [HTTP::header value Content-Type] contains "text" || [HTTP::header value Content-Type] contains "xml" } {
    
         Replace http with https, xyz.com:4444 with xyz.com 
        STREAM::expression [list {@http:\@https:\@} {@xyz.com:4444@xyz.com@} ] 
    
         Enable the stream filter for this response only 
        STREAM::enable 
     } 
    
    }
    
    when STREAM_MATCHED {
       Log each match found by the stream filter
      log local0. "Stream filter matched: [STREAM::match]"
    }
    

    N.B: Add a stream profile and you can check the logs in /var/log/ltm normally if the rewrite works fine, it will logs each match found...

    Waiting for you feedback

    Regards