HTTP URL Redirect on Oracle Cloud Infrastructure

April 9, 2020 | 6 minute read
Ajay Chhabria
Principal Product Manager
Text Size 100%:

We're pleased to announce that you can now configure URL redirects for HTTP traffic in Oracle Cloud Infrastructure. This post discusses several common use cases of this feature and provides configuration details for a successful deployment.

Overview

You use redirects when you move content to a new URL, delete pages, change domain names, or merge websites. A URL redirect tells users what you want them to see instead of what they asked to see. With the URL redirect functionality, you can redirect insecure connections to secure HTTPS, achieve domain aliasing, and keep old links active after a page has been decommissioned, all of which enhance the user experience.

Oracle Cloud Infrastructure provides two ways to implement URL redirects:

  • Load Balancer URL Redirect: Redirect service performed by the Oracle Cloud Infrastructure Load Balancing service for incoming HTTP requests.
  • Global URL Redirect: Redirect service for public-facing domain names by using an Oracle Cloud Infrastructure managed authoritative DNS. With the DNS, you can place an HTTP redirect on any DNS hostname. Any requests for the hostname are forwarded to an HTTP redirect server that provides the URL redirect to the end user. Oracle Cloud Infrastructure maintains a fleet of geographically distributed redirection servers to perform this redirection.

Enterprises that want to redirect on a global level can apply the DNS-deployed redirect service for all users who access a DNS name, rather than letting users connect to a regional load balancer only to learn of a redirect. For example, a user in Tokyo can be redirected from a redirect server in Japan rather than connecting to a load balancer in Ashburn, Virginia, which saves time for the user. Alternatively, enterprises that want to redirect on a regional level and use a private network can apply the load balancer redirect service.

Redirects are implemented by passing an HTTP response status code to the user that indicates a new location to fulfill their request. You can set a 301 code for a permanent redirect, a 302 code for a temporary redirect, or other redirect codes. These codes help control which user requests are served by your applications. You can even use these status codes to help users access your site—a 301 redirect, for example, tells users that a page has moved somewhere else permanently.

Use Cases

Following are some use cases for URL redirects.

Redirect Insecure Customer Requests to Enforce HTTPS Everywhere

You want users to access your website over HTTPS. To maintain the highest level of security, you update your website from HTTP to HTTPS protocol, and then you redirect all unencrypted HTTP traffic to encrypted HTTPS.

Temporarily Redirect Traffic While Performing Maintenance

You want to avoid user dissatisfaction while browsing your website. For example, you have multiple web servers that are being load balanced, but a change is required to all of them at once, and you want the public users to temporarily redirect to another website hosted on another URL. You notify users with a "Web page under construction" message on the browser while the servers are out of commission.

Move an Entire Domain to Another Domain

You want users to use old URLs and still get the latest content. Following are some examples:

  • Company A has been acquired by Company B. You want users to be redirected to Company B's domain when they browse using Company A's domain.
  • Company A owns example.net and example.com, and you want all HTTP traffic for example.net to always redirect to example.com. This mapping is one-to-one. You can also use wildcard mapping. To redirect an entire domain, you would deploy a global redirect on the apex of the DNS zone example.com and on *.example.com to cover any potentially queried host names against the domain.

Redirect a FQDN to a Specific URL

You don't want users to have to remember a long URL, but just the subdomain name. For example, you don't want users to have to remember lengthy URLs to browse products on our website. So, for example, you set product.example.com to redirect to https://www.example.com/product/login.

Redirect a Subdomain to a URL with a Port Number

A user wants to access their service without typing the port number each time. For example, camera.example.com could redirect to http://office.example.com:8080.

Common Architecture

The following image shows the steps that happen when a user's URL is redirected by a load balancer that has a DNS name associated with it (dotted line) or a standalone server as part of a global DNS fleet (solid line).

  1. The user's browser starts a DNS query to the ISP recursive resolver.
  2. The recursive name server navigates the authoritative DNS for the domain oracle.DNSDemos.com, ultimately sending the request to the Oracle Cloud Infrastructure DNS, the authoritative DNS for the domain.
  3. The ISP recursive resolver receives the CNAME/A record for the HTTP redirect server (redirect.waf.oci.oraclecloud.net). The ISP recursive resolver repeats this process until it has an IP address to provide the client.
  4. The ISP resolver sends the IP address to the client. At this point, the DNS resolution is completed.
  5. The browser (client) automatically sends an HTTP request to the HTTP redirect server redirect.waf.oci.oraclecloud.net using its IP address. If there is a load balancer, the redirect is handled by the load balancer itself.
  6. In either scenario, the redirect server or load balancer responds with an HTTP reply (301 Redirect) redirecting to the new destination server (http://www.oracle.com).

Note: If you're configuring a URL redirect on the load balancer and enter the IP address directly, bypassing DNS, steps 5 and 6 are the only steps.

Load Balancer URL Redirect

You can use load balancer-based URL redirect if you want to load balance your backends and redirect HTTP(S) traffic. You can perform these redirects directly on the load balancer, which eliminates the need for additional backend resources to perform redirection. Load balancer supports all permutations between HTTP and HTTPS. By contrast, DNS URL redirect doesn't manage certificates and can therefore only redirect from HTTP to HTTPS, not the other way around.

Configure URL Redirect on the Load Balancer

To configure URL redirect on the load balancer, see the information in Managing Rule Sets.

The following example shows configuring a URL redirect rule on the load balancer to redirect HTTP traffic to HTTPS with a response code of 301 - Moved Permanently and a new location of /videos, keeping the query same as the original request.

Once you have created the Rule Set, you need to attach it to a Listener.

As a result, when you type http://<loadbalancerip>/ in your browser, the page is redirected to http://<loadbalancerip>/video.

Global URL Redirect

Global URL redirect lets you redirect HTTP traffic on a defined hostname to an HTTP(S) destination with options to define a path and port if the scope is global and not limited to a particular availability domain or region. Use this option when users are accessing the external-facing DNS "Internet DNS" involved in the architecture. Use this option to redirect only public-facing domain names, versus load balancer-based URL redirect, which can redirect within a private network.

Create and Manage Your DNS Zones

You can create the zone manually or import a zone file. Note that SOA and NS records for imported zones will be overwritten in order to be associated with Oracle's name servers. Redirect can be used only with a zone that uses Oracle Cloud Infrastructure DNS for the primary DNS, where Oracle Cloud Infrastructure has control of zone file modification. Redirect can't be used with secondary DNS servers because Oracle Cloud Infrastructure has a read-only copy of the zone and the service can't be added.

For more information about zones, see Managing DNS Service Zones.

Create an HTTP Redirect Using DNS

For configuration information, see Managing HTTP Redirects.

The following example shows configuring HTTP redirect to redirect the subdomain oracle.DNSDemos.com to http://www.oracle.com:80 with a response code of 301 - Moved Permanently.

Verify URL Redirection

Open a terminal window on your laptop, and run the following command, for example:

$ curl -s -I oracle.DNSDemos.com
HTTP/1.1 301 Moved Permanently
Via: 1.1
Date: Fri, 13 Mar 2020 03:55:31 GMT
Server: ZENEDGE
Location: HTTP://www.oracle.com:80

The response confirms that URL redirects are working as expected.

Summary

This post shows two ways to configure a URL redirect with minimal configuration and easy steps. I hope that you enjoyed this introduction to URL redirects. Now, when you design your website on Oracle Cloud Infrastructure, you can use this feature to let you smartly migrate or change URLs. To learn more about the load balancer feature, see URL Redirect Rules. For more information about global-based redirects, see Managing HTTP Redirects.

Ajay Chhabria

Principal Product Manager


Previous Post

Top 10 Capabilities of Autonomous Database Technology

Guest Author | 3 min read

Next Post


Hadoop Across Regions on Oracle Cloud Infrastructure

Zachary Smith | 4 min read