# URL Redirect iRule Question

**URL:** <https://community.f5.com/t/url-redirect-irule-question/57716>\
**Category:** Technical Forums\
**Tags:** irules, big-ip-access-policy-manager-apm, security, devops, application-delivery\
**Created:** [September 10, 2013, 7:06pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716 "2013-09-10T19:06:42Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![kend](https://avatars.discourse-cdn.com/v4/letter/k/5f9b8f/32.png) [@kend](https://community.f5.com/u/kend)\
**Post date:** [September 10, 2013, 7:06pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/1 "2013-09-10T19:06:42Z")

</div>

Can anyone tell me if the action below is possible using an iRule or some other method on the LTM?

User connects to [www1.abc.com](http://www1.abc.com). The LTM redirects this to [abc.corp.com](http://abc.corp.com). But, the user still needs to see [www1.abc.com](http://www1.abc.com) in their browser bar even thogh they have been redirected to [abc.corp.com](http://abc.corp.com).

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [September 10, 2013, 7:19pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/2 "2013-09-10T19:19:17Z")

</div>

You could technically route the traffic _ **through** _ the LTM. Set the pool to point to [abc.corp.com](http://abc.corp.com) and make sure the LTM has a route to this address. Depending on the complexity of the remote application, you may need to rewrite links and object references coming from that remote site, which could either be done with a STREAM profile (for simple stuff) or ProxyPass (for more complicated environments).

---

<div class="post-metadata">

**Author:** ![kend](https://avatars.discourse-cdn.com/v4/letter/k/5f9b8f/32.png) [@kend](https://community.f5.com/u/kend)\
**Post date:** [September 12, 2013, 8:58pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/3 "2013-09-12T20:58:17Z")

</div>

Will the ProxyPass iRule in the CodeShare section do what I am asking?

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [September 12, 2013, 9:08pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/4 "2013-09-12T21:08:49Z")

</div>

What you’re asking for could be really easy, or really hard, and it depends entirely on the application you’re sitting in front of. For example, just to go to Google Docs, the browser touches no less than 35 separate servers. This would be a nightmare to proxy even for ProxyPass. If the application is not _ **that** _ complicated, then I’d say ProxyPass would be a good fit. The idea is that the remote application would IP space would be assigned to a pool, and ProxyPass would rewrite incoming and outgoing URL references.

---

<div class="post-metadata">

**Author:** ![kend](https://avatars.discourse-cdn.com/v4/letter/k/5f9b8f/32.png) [@kend](https://community.f5.com/u/kend)\
**Post date:** [September 13, 2013, 1:33pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/5 "2013-09-13T13:33:07Z")

</div>

Fortunately, it is not a complicated application. I am trying the ProxyPass iRule, but it is not working. When I connect to [www1.abc.com](http://www1.abc.com), the URL in my browser bar changes to “[http://www1.abc.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/](http://www1.abc.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/abc.corp.com/)” and I recieve a “Server Error in ‘/’ Application. Runtime Error…” page.

---

<div class="post-metadata">

**Author:** ![kend](https://avatars.discourse-cdn.com/v4/letter/k/5f9b8f/32.png) [@kend](https://community.f5.com/u/kend)\
**Post date:** [September 13, 2013, 4:33pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/6 "2013-09-13T16:33:25Z")

</div>

I corrected the problem I stated above. But, now, when I connect, I don’t get to the webpage and the following messages are placed in the LTM log.

Rule ProxyPass : VS=vs\_abc\_http, [Host=abc.corp.com](http://Host=abc.corp.com), URI=/: No rule found, using default pool pool\_abc\_http\_https and exiting

Rule ProxyPass : VS=vs\_abc\_http, [Host=abc.corp.com](http://Host=abc.corp.com), URI=/welcome.png: No rule found, using default pool pool\_abc\_http\_https and exiting

Rule ProxyPass : VS=vs\_abc\_http, [Host=abc.corp.com](http://Host=abc.corp.com), URI=/welcome.png: No rule found, using default pool pool\_abc\_http\_https and exiting

Rule ProxyPass : VS=vs\_abc\_http, [Host=abc.corp.com](http://Host=abc.corp.com), URI=/favicon.ico: No rule found, using default pool pool\_abc\_http\_https and exiting

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [September 13, 2013, 4:53pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/7 "2013-09-13T16:53:02Z")

</div>

What does your data group look like? At a minimum you should have something like this:

```tcl
www1.abc.com/ := abc.corp.com/

```

Where the users access the VIP using the [www1.abc.com](http://www1.abc.com) URL and ProxyPass translates that to the [abc.corp.com](http://abc.corp.com) URL.

---

<div class="post-metadata">

**Author:** ![kend](https://avatars.discourse-cdn.com/v4/letter/k/5f9b8f/32.png) [@kend](https://community.f5.com/u/kend)\
**Post date:** [September 13, 2013, 8:35pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/8 "2013-09-13T20:35:03Z")

</div>

Well, I found out some new information today from our web server team and I think that is why the iRule is not working. [www1.abc.com](http://www1.abc.com) is a web server with an external IP of x.x.x.x. The web server [abc.corp.com](http://abc.corp.com) is in a pool on the LTM which is assigned to the virtual server. [www1.abc.com](http://www1.abc.com) is configured to redirect to the IP of the virtual server of the LTM which resolves to [abc.corp.com](http://abc.corp.com). So, the LTM sees the request coming from [abc.corp.com](http://abc.corp.com) and the iRule does not work since the data group is set for [www1.abc.com/](http://www1.abc.com/) := [abc.corp.com/](http://abc.corp.com/). So, it doesn’t appear this iRule will work since the users are not connecting directly to the LTM.

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [September 13, 2013, 10:08pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/9 "2013-09-13T22:08:13Z")

</div>

I think there’s something missing here. You have a web server ([www1.abc.com](http://www1.abc.com)) that redirects to [abc.corp.com](http://abc.corp.com). My understanding from what you’ve said is that [abc.corp.com](http://abc.corp.com) is both a VIP on the BIG-IP **AND** a (remote) web server sitting in a pool behind the BIG-IP. Is that correct?

---

<div class="post-metadata">

**Author:** ![kend](https://avatars.discourse-cdn.com/v4/letter/k/5f9b8f/32.png) [@kend](https://community.f5.com/u/kend)\
**Post date:** [September 16, 2013, 3:30pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/10 "2013-09-16T15:30:27Z")

</div>

Let me try and clarify. [www1.abc.com](http://www1.abc.com) is a web server with a public IP of x.x.x.x. [abc.corp.com](http://abc.corp.com) is a web server that is in a pool on the LTM. That pool is assigned to a virtual server on the LTM. That virtual server has a public IP of y.y.y.y. When the user connects to [www1.abc.com](http://www1.abc.com), it redirects them to the virtual server IP of y.y.y.y and then to the pool with [abc.corp.com](http://abc.corp.com). So, since [www1.abc.com](http://www1.abc.com) is redirecting the connection to the VS IP, the LTM sees the request as coming from [abc.corp.com](http://abc.corp.com). The iRule and data group would work if the user connected directly to the LTM as [www1.abc.com](http://www1.abc.com) and did not get redirected from a that server. Does that make sense?

---

<div class="post-metadata">

**Author:** ![RickM](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@RickM](https://community.f5.com/u/RickM)\
**Post date:** [September 16, 2013, 3:40pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/11 "2013-09-16T15:40:33Z")

</div>

Sounds to me like you don’t really want a redirection, but there may be more to your requirements than you have shared.

---

<div class="post-metadata">

**Author:** ![kend](https://avatars.discourse-cdn.com/v4/letter/k/5f9b8f/32.png) [@kend](https://community.f5.com/u/kend)\
**Post date:** [September 16, 2013, 3:46pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/12 "2013-09-16T15:46:43Z")

</div>

The reason for the redirect is that [www1.abc.com](http://www1.abc.com) is owned by a company that we purchased and we are trying to migrate the users off of the web server without too much disruption to the users. [www1.abc.com](http://www1.abc.com) is in that company’s IP block and [abc.corp.com](http://abc.corp.com) is in our IP block. That is why we are redirecting.

---

<div class="post-metadata">

**Author:** ![RickM](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@RickM](https://community.f5.com/u/RickM)\
**Post date:** [September 16, 2013, 3:58pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/13 "2013-09-16T15:58:09Z")

</div>

Sending a redirect tells the browser to go ask someone else. You’ll then see that host in the browser’s bar. If you want www1 to appear in the bar, you’ll have to accept requests and send replies from www1 instead of redirecting it somewhere else.

---

<div class="post-metadata">

**Author:** ![kend](https://avatars.discourse-cdn.com/v4/letter/k/5f9b8f/32.png) [@kend](https://community.f5.com/u/kend)\
**Post date:** [September 16, 2013, 4:37pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/14 "2013-09-16T16:37:55Z")

</div>

Yes, I understand that. But [www1.abc.com](http://www1.abc.com) needs to still resolve to the existing public IP until we can migrate the DNS over to our IP. So, in that interim, we wanted to keep [www1.abc.com](http://www1.abc.com) in the browser bar but have the connection actually be to [abc.corp.com](http://abc.corp.com) on the LTM.

---

<div class="post-metadata">

**Author:** ![RickM](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@RickM](https://community.f5.com/u/RickM)\
**Post date:** [September 16, 2013, 4:47pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/15 "2013-09-16T16:47:25Z")

</div>

Kevin Stewart had a good answer for that, but maybe the stream/proxypass stuff distracted you.

To re-state his answer:

virtual: [www1.abc.com](http://www1.abc.com)

pool: contains [abc.corp.com](http://abc.corp.com) server

no redirects. Browse the site as [www1.corp.com](http://www1.corp.com). Is anything broken? Can it be fixed on the back-end, within the web application? No? Then you need to try to use stream or proxypass to rewrite URLs within the http conversation so that the app works properly.

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [September 17, 2013, 12:42pm UTC](https://community.f5.com/t/url-redirect-irule-question/57716/16 "2013-09-17T12:42:00Z")

</div>

The problem is this:

**[www1.corp.com](http://www1.corp.com)** resolves to a public IP address and a server that (I assume) sits somewhere else (at least it doesn’t go through the LTM).

**Your VIP** has a separate public IP address. Because the users are external to your environment, the only real control you have is via DNS and address resolution. [www1.corp.com](http://www1.corp.com) resolves to one physical address and your VIP resolves to another, and you can’t have [www1.corp.com](http://www1.corp.com) resolve to your VIP unless you’re actually taking it over. You simply cannot have the browser show [www1.corp.com](http://www1.corp.com) in the address bar but be going to your VIP (a different URL). You could:

1. Flip DNS to point to your VIP and have the traffic pass through the LTM to get to the original server (least intrusive method).

2. Have the original server redirect to a URL that is only subtlety different.

3. Or simply have the original server redirect to a _ **NEW** _ (and improved) URL.
