# Reverse Proxy Redirect

**URL:** <https://community.f5.com/t/reverse-proxy-redirect/9464>\
**Category:** Technical Forums\
**Tags:** big-ip, devops, ltm, application-delivery\
**Created:** [March 13, 2017, 5:53pm UTC](https://community.f5.com/t/reverse-proxy-redirect/9464 "2017-03-13T17:53:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robberhines\_120](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@Robberhines\_120](https://community.f5.com/u/Robberhines_120)\
**Post date:** [March 13, 2017, 5:53pm UTC](https://community.f5.com/t/reverse-proxy-redirect/9464/1 "2017-03-13T17:53:29Z")

</div>

First off apologies that this has been asked and answered before but I can’t seem to get it work correctly, so maybe I am not searching correctly.

So the pretty simple explanation of what we are trying to do is this: On the surface person goes to and without changing the url for SEO reasons we want to load data from [locations.domain.com](http://locations.domain.com) which is just a CNAME for another domain that is going to be called ran by a 3rd party company.

I have tried to write iRules and have had no such luck and have even tried to use the ProxyPass iRule with no luck. I’m not very handy at writing these iRules and having trouble getting what should be something simple to work.

---

<div class="post-metadata">

**Author:** ![Robberhines\_120](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@Robberhines\_120](https://community.f5.com/u/Robberhines_120)\
**Post date:** [March 13, 2017, 7:24pm UTC](https://community.f5.com/t/reverse-proxy-redirect/9464/2 "2017-03-13T19:24:50Z")

</div>

Sorry I should have added what I have so far:

```tcl
when HTTP_REQUEST { 
    if { ([string tolower [HTTP::host]] == "www.domain.com") and (([string tolower [HTTP::uri]] contains "/locations")) } {
        log local0. "Test Redirect iRule Triggered"
        HTTP::redirect "locations.domain.com[HTTP::path]"
        log local0. "[HTTP::host][HTTP::path]"
    }
}

```

So what I have naturally is a redirect that catches /locations but I am unsure the next steps to make the F5 just get the contents of [http://locations.domain.com](http://locations.domain.com) to make it still look like its coming from [http://www.domain.com/locations](http://www.domain.com/locations)

---

<div class="post-metadata">

**Author:** ![Stephane\_Viau](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@Stephane\_Viau](https://community.f5.com/u/Stephane_Viau)\
**Post date:** [March 13, 2017, 7:32pm UTC](https://community.f5.com/t/reverse-proxy-redirect/9464/3 "2017-03-13T19:32:07Z")

</div>

I think what you want to do is transparently rewriting the URL instead of sending the browser a redirect, no? Is your concern that the client browser sees the change and you want to avoid that behavior?

---

<div class="post-metadata">

**Author:** ![Robberhines\_120](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@Robberhines\_120](https://community.f5.com/u/Robberhines_120)\
**Post date:** [March 13, 2017, 7:51pm UTC](https://community.f5.com/t/reverse-proxy-redirect/9464/4 "2017-03-13T19:51:18Z")

</div>

Correct, our clients concern is that they don’t, for SEO reasons and such to not have [locations.domain.com](http://locations.domain.com) crawled. They want to make all requests to /locations look like it’s coming from even though they are not.

---

<div class="post-metadata">

**Author:** ![Stephane\_Viau](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@Stephane\_Viau](https://community.f5.com/u/Stephane_Viau)\
**Post date:** [March 13, 2017, 8:29pm UTC](https://community.f5.com/t/reverse-proxy-redirect/9464/5 "2017-03-13T20:29:21Z")

</div>

Simple answer is you can change values for the host and the path before the request is passed on to the backend servers. For example :

```tcl
when HTTP_REQUEST {
  HTTP::header replace "Host" "locations.domain.com"
  HTTP::path "/"
}

```

This would transparently rewrite whatever you had before to [http://locations.domain.com/](http://locations.domain.com/) .

But, this might cause your application to misbehave. The reason for this is that your app server doesn’t know about the rewriting that’s happening, and so it will generate HTML code and cookies and such based on what it sees, which is different from what the client sees. So for example, your app server could generate a cookie for [locations.domains.com](http://locations.domains.com) but the client still sees the old name . Therefore the client will not try to re-use the cookie because from its point of view the cookie does not match the site name.

So in this case you will need to use a Rewrite Profile (Profiles --\> Services --\> Rewrite) to try to rewrite everything that’s coming in and back out until your app works correctly. This could be time consuming unfortunately but I don’t know of a better way to do it. Look at this piece of documentation here about URI translation :

> **[404 Page not found | BIG-IP Documentation](https://techdocs.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/ltm-implementations-11-4-0/21.html)**
>
> Usage information and technical documentation for BIG-IP and other related F5 products
