Forum Discussion

Wendi_Goulette_'s avatar
Wendi_Goulette_
Icon for Nimbostratus rankNimbostratus
Jun 10, 2014

ProxyPass 302 redirect possible?

Hello, I just implemented the ProxyPass irule for some headerrewrites and it's working beautifully. The only thing is my customer wants me to also do a redirect if the URL matches a certain string.

 

This part works: /oldurl?useringormation1234456 is to be rewritten to /newurl?useringormation1234456 while leaving /oldurl?useringormation1234456 in the browser.

 

This part does not work: /oldurl/ is to be redirected to somename.elsewhere.com. I've tried using several methods in my data group but it does not seem to be working. I even created a pool with the somename.elsewhere.com:80 as a member and tried sending it there and also created a virtual server that does nothing but redirect to somename.elsewhere.com and nothing is working.

 

Does anyone have any suggestions on how to make proxypass do a good old fashioned 302 redirect?

 

Thanks!

 

  • Proxypass does not include redirect functionality that you can use for this. It only modifies traffic on the way to the server.

    Your better off adding an iRule to do it.

    when HTTP_REQUEST {
      if {[class search myclass equals "[HTTP::host][HTTP::uri]"]} {
        HTTP::redirect [class search -value myclass equals "[HTTP::host][HTTP::uri]"]
      }
    }
    

    Then class myclass should contain text of the form...

    Key              Value
    old.host.com/url http://new.host.com/newurl
    old.host.com/url http://new.host.com/
    old.host.com/url /mynewurl
    
  • Please can you paste the iRule you are working on. Make it a bit easier. When you paste, make sure you select the iRule and press Tab before you submit. This makes it a code block and provides syntax highlighting.
  • It's the standard proxypass irule. No modifications except I've got logging enabled. https://devcentral.f5.com/s/articles/proxypass-v10-v11
  • Proxypass does not include redirect functionality that you can use for this. It only modifies traffic on the way to the server.

    Your better off adding an iRule to do it.

    when HTTP_REQUEST {
      if {[class search myclass equals "[HTTP::host][HTTP::uri]"]} {
        HTTP::redirect [class search -value myclass equals "[HTTP::host][HTTP::uri]"]
      }
    }
    

    Then class myclass should contain text of the form...

    Key              Value
    old.host.com/url http://new.host.com/newurl
    old.host.com/url http://new.host.com/
    old.host.com/url /mynewurl