Forum Discussion

whootang's avatar
whootang
Icon for Nimbostratus rankNimbostratus
Mar 22, 2015

Issue with URI rewrite

Hi Guys,

 

Having some issues on a rewrite rule I'm trying to create (sorry first time looking at these)

 

I am trying to copy a rule we have in apache at the moment.

 

RewriteCond %{HTTP_HOST} ^support.yourdomain.com$ [NC]

 

RewriteRule ^/(.*)$ https://support.3rdpartywebsite.com/$1 [P,L]

 

So when our users enter support.yourdomain.com it goes off to support.3rdpartywebsite.com I am assuming and want the end user to not know that support.3rdpartywebsite.com URL and hit it direct.

 

This is what I have so far but it dosent seem to work any tips?

 

if { [HTTP::uri] equals "support.yourdomain.com" } { HTTP::uri "https://support.3rdpartywebsite.com" } }

 

Thanks R

 

2 Replies

  • So when our users enter support.yourdomain.com it goes off to support.3rdpartywebsite.com I am assuming and want the end user to not know that support.3rdpartywebsite.com URL and hit it direct.

    if you just want to change http host header in request only, you can use HTTP::header replace command but if support.3rdpartywebsite.com is also embedded in response body (so, you have to rewrite it back to support.yourdomain.com), you may need to use proxypass which Mark suggested.

    e.g.

     config
    
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
    ltm virtual bar {
        destination 172.28.24.10:80
        ip-protocol tcp
        mask 255.255.255.255
        pool foo
        profiles {
            http { }
            tcp { }
        }
        rules {
            qux
        }
        source 0.0.0.0/0
        source-address-translation {
            type automap
        }
        vs-index 19
    }
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm pool foo
    ltm pool foo {
        members {
            200.200.200.101:80 {
                address 200.200.200.101
            }
        }
    }
    root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux
    ltm rule qux {
        when HTTP_REQUEST {
      if { [HTTP::host] eq "support.yourdomain.com" } {
        HTTP::header replace Host "support.3rdpartywebsite.com"
      }
    }
    }
    
     trace
    
    [root@ve11c:Active:In Sync] config  ssldump -Aed -nni 0.0 port 80
    New TCP connection 1: 172.28.24.1(53863) <-> 172.28.24.10(80)
    1427071308.3080 (0.0279)  C>S
    ---------------------------------------------------------------
    GET /someting HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
    Accept: */*
    Host: support.yourdomain.com
    
    ---------------------------------------------------------------
    
    New TCP connection 2: 200.200.200.14(53863) <-> 200.200.200.101(80)
    1427071308.3122 (0.0030)  C>S
    ---------------------------------------------------------------
    GET /someting HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
    Accept: */*
    Host: support.3rdpartywebsite.com
    
    ---------------------------------------------------------------