Forum Discussion

jonathanw84's avatar
Apr 30, 2020

ProxyPass Replacement Question

Hello,

 

I have a customer who needs an environment set up that will be replacing their Apache environment. I have the VS set up but am not confident on how I should go about setting up the reverse proxy piece. I created a rewrite profile but am also interested in a related iRule. Here is what is being requested:

 

ProxyPass /apps/locale ----> http://server1:8103/SharedPHP/locale

ProxyPass /apps ----> http://server1:8103/Resources2011Apps/

ProxyPass /cdn ----> http://server2:8100/cdn/

ProxyPass / ----> http://server2:8100/

 

Is the URI rewrite profile the correct way to do this? I set up something as follows for example for the rewrite profile:

 

Rule Type:

Both

 

Client URI:

/apps/locale/

 

Server URI:

http://server1:8103/SharedPHP/locale

 

Can someone also provide an example of how I would achieve this with an iRule as well?

 

Thanks!

 

 

4 Replies

  • Hi,

     

    You can achieve it using iRule or LTM policy. One example iRule is given below. You can try it. First you need to configure Virtual Server with proper configuration and bind below iRule to it.

     

    when HTTP_REQUEST {

    if { [HTTP::host] contains "abc.com" }{

    if { [HTTP::uri] starts_with "/apps/locale/" }{ 

    HTTP::redirect http://abc.com/SharedPHP/locale/

    }} }

     

    Hope it helps!

    Mayur

  • Thanks Mayur.

     

    The only thing about that is that we don't want the client to see the redirect take place, hence the reverse proxy configuration. Here is what I've done and I cannot seem to get it to work.

     

    I've created two different pools (pool1 and pool2)

     

    I've created an iApp that has a VS with no pool members.

     

    I created an iRule that states the following:

     

    when HTTP_REQUEST {

    if { [string tolower [HTTP::uri]] starts_with "/apps/locale/" }{

        pool pool_1

      }

    elseif { [string tolower [HTTP::uri]] starts_with "/apps/" }{

        pool pool_1

      }

    elseif { [string tolower [HTTP::uri]] starts_with "/cdn/" }{

        pool pool_2

      }

    elseif { [string tolower [HTTP::uri]] starts_with "/" }{

        pool pool_2

      }

    }

     

    And I've also created a rewrite profile that rewrites the client URI request and applied this to the virtual server.

     

    Client URI: /apps/locale ----> Server URI: http://server1:8103/SharedPHP/locale

    Client URI: /apps ----> Server URI: http://server1:8103/Resources2011Apps/

    Client URI: /cdn ----> Server URI: http://server2:8100/cdn/

    Client URI: / ----> Server URI: http://server2:8100/

     

    It does not work. Originally I was trying to put all of the servers into the same VS but because the nodes provides different functions, it was trying to load balance between them and this was causing it not to work.

     

    Any assistance would be greatly appreciated!

     

  • I am having the same issue's did you manage to resolve this?

    • jonathanw84's avatar
      jonathanw84
      Icon for Cirrus rankCirrus

      Hello,

       

      Yes, I was able to resolve this. I utilized a combination of a rewrite profiles and iRules to accomplish what I need. Essentially, the rewrite profile takes care of the URI translations and if you will need different URIs going to different back end servers, an iRule can help achieve this.

       

      I utilized this tutorial to help me with configuration:

       

      https://techdocs.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/ltm-implementations-12-1-0/17.html

       

      Let me know if you need any additional assistance.

       

      Thanks!