URL Redirect iRule Question

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. The LTM redirects this to abc.corp.com. But, the user still needs to see www1.abc.com in their browser bar even thogh they have been redirected to abc.corp.com.

You could technically route the traffic through the LTM. Set the pool to point to 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).

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

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.

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, 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/” and I recieve a “Server Error in ‘/’ Application. Runtime Error…” page.

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, URI=/: No rule found, using default pool pool_abc_http_https and exiting

Rule ProxyPass : VS=vs_abc_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, 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, URI=/favicon.ico: No rule found, using default pool pool_abc_http_https and exiting

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

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

Where the users access the VIP using the www1.abc.com URL and ProxyPass translates that to the abc.corp.com URL.

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 is a web server with an external IP of x.x.x.x. The web server abc.corp.com is in a pool on the LTM which is assigned to the virtual server. www1.abc.com is configured to redirect to the IP of the virtual server of the LTM which resolves to abc.corp.com. So, the LTM sees the request coming from abc.corp.com and the iRule does not work since the data group is set for www1.abc.com/ := abc.corp.com/. So, it doesn’t appear this iRule will work since the users are not connecting directly to the LTM.

I think there’s something missing here. You have a web server (www1.abc.com) that redirects to abc.corp.com. My understanding from what you’ve said is that 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?

Let me try and clarify. www1.abc.com is a web server with a public IP of x.x.x.x. 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, it redirects them to the virtual server IP of y.y.y.y and then to the pool with abc.corp.com. So, since www1.abc.com is redirecting the connection to the VS IP, the LTM sees the request as coming from abc.corp.com. The iRule and data group would work if the user connected directly to the LTM as www1.abc.com and did not get redirected from a that server. Does that make sense?

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

The reason for the redirect is that 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 is in that company’s IP block and abc.corp.com is in our IP block. That is why we are redirecting.

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.

Yes, I understand that. But 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 in the browser bar but have the connection actually be to abc.corp.com on the LTM.

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

pool: contains abc.corp.com server

no redirects. Browse the site as 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.

The problem is this:

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 resolves to one physical address and your VIP resolves to another, and you can’t have www1.corp.com resolve to your VIP unless you’re actually taking it over. You simply cannot have the browser show 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.