Data Flow – F5 HTTP/S Root (Apex) Redirect to Subdomain and How DNS Works

SCENARIO

F5 Redirect Setup for Root (Apex) to WWW (cordero.me > www.cordero.me)
Root (Apex) “cordero.me” IP = 10.1.1.1
WWW “www.cordero.me” = 192.168.1.1

DATA FLOW

The flow would look something like this:
1. A client makes a request for `https://cordero.me`.
2. The client’s DNS resolver queries for the IP address of `cordero.me`.
3. The DNS server returns the IP address 10.1.1.1.
4. The client sends the HTTP request to 10.1.1.1.
5. Assuming that 10.1.1.1 is the IP address of the F5 Load Balancer, the F5 receives the request and applies the redirect rule.
6. The F5 Load Balancer sends a response back to the client with a 301 or 302 HTTP status code, indicating the new location `https://www.cordero.me`.
7. The client receives the redirect response and makes a new DNS query for the IP address of `www.cordero.me`.
8. The DNS server returns the IP address 192.168.1.1.
9. The client sends the HTTP request to 192.168.1.1, which is presumably the IP address of the desired web server.
10. The web server at 192.168.1.1 processes the request and returns the response to the client.

 

F5 REDIRECT RULE

In F5, you can create an iRule to handle the redirect from the root domain to the www subdomain. iRules are a powerful feature in F5 that enable you to manage network traffic by configuring custom scripts.

Please note that the exact steps can vary depending on the version of the BIG-IP system you’re using. Here’s a general example:

1. Log into your F5 BIG-IP system.
2. Go to the iRules section. This is typically located under “Local Traffic” > “iRules” > “iRule List“.
3. Create a new iRule. Click on “Create“, give your new iRule a name (e.g., “Redirect_Root_to_WWW“), and enter the following script in the “Definition” section:

    when HTTP_REQUEST {
        if { [HTTP::host] equals "cordero.me" } {
            HTTP::respond 301 Location "http://www.cordero.me[HTTP::uri]"
        }
    }

This iRule triggers when an HTTP request is made. If the host is “cordero.me“, it responds with a 301 redirect to “www.cordero.me” while preserving the URI path and query.

4. Apply the iRule to a virtual server. Go to “Local Traffic” > “Virtual Servers” and select the virtual server handling traffic for “cordero.me“. Under “Resources“, find the “iRules” section and add your newly created iRule.

5. Save and Apply Changes.

After these steps, all HTTP requests to “cordero.me” should be redirected to “www.cordero.me”. If you’re using HTTPS, remember to change “http” to “https” in the iRule and make sure your F5 setup can handle SSL/TLS traffic.