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.
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:
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.
Following are some use cases for URL redirects.
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.
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.
You want users to use old URLs and still get the latest content. Following are some examples:
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.
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.
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).
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.
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.
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 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.
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.
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.
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.
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.