Forum Discussion

ottleydamian's avatar
Mar 13, 2019

Rewrite URI & protocol and send to a node

Scenario:

  1. An https request comes in 2. Modify the URI 3. Modify the protocol to http 4. Do a DNS lookup for the node 5. Forward the request to the node

Number 3 & 5 is what I'm having issues with. Every thing else works but it doesn't send anything to the node and I don't know a command to call to change the protocol (like URI::protocol, which seems to only read the protocol but I don't think it can be used to change the protocol).

Using logs messages I verified that the URI was changed as needed and the node has the right IP address from DNS but will changing the URI send the request on (forward)? And how do I change the protocol?

Below is an example of what I am thinking:

when HTTP_REQUEST {
set myURI [string range [HTTP::uri] 1 end]
scan $myURI {%[^/]/%s} var1 var2
set myDNS $var1.domain.biz
HTTP::uri $var1.domain.biz/$var2
set myNode [RESOLV::lookup @$static::@8.8.8.8 -a $myDNS]

if {$myNode ne ""}{
node [lindex $myNode 0]
}

4 Replies

  • Because I can't test at the moment, do you think the following will change the protocol from http to https:

    HTTP::uri $var1.domain.biz:80/$var2

  • Hi

     

    Normally if your pool is HTTP (i.e. no server ssl profile assigned to you VS), and your VS is HTTPS (i.e. client ssl profile is assigned), you do not need to change that. BUT if in the response from your backend you have hardcoded absolute links rather than relative path (in HREF tags for example), then you need to rewrite teh response towards the client.

     

    If this is not what you are trying to achieve, let us know.

     

    Thanks

     

  • Yoann thanks for your help. The request are beginning sent to the backend device. My HTTP::uri may have been missing a / but in general it is modifying and sending the rewrite.

     

    I’m still working out other bugs but I understand the rewrite process a lot more now.

     

    • Yoann_Le_Corvic's avatar
      Yoann_Le_Corvic
      Icon for Nimbostratus rankNimbostratus

      Glad it helped. And good luck for the next steps.

       

      Consider marking my answer, that would be great.