Ingress Redirection

Last updated: 2021-10-13 14:29:33

    Overview

    Domain name redirection means when you access a URL in a browser, the web server is set to automatically redirect to another URL.

    Use Cases

    • The website supports HTTP and HTTPS; for example, http://tencent.com and https://tencent.com need to point to the same web service.
    • The domain name of the website has changed, for example, from https://tengxun.com to https://tencent.com, and the two domain names point to the same web service.
    • The website content has been partially adjusted and is no longer accessible at the original URL; in this case, it can be redirected to a new URL that provides services.
    Note
    • After you use redirection, there will be an additional annotation, which indicates that the forwarding rule of the Ingress is managed by TKE and cannot be deleted or modified subsequently; otherwise, it will conflict with the redirection rule set in CLB.
      ingress.cloud.tencent.com/rewrite-support: "true"
    • If a letter is used to represent the domain name address, and A has been redirected to B, then:
      • A cannot be redirected to C (unless you delete the old redirection relationship first and then create a new one).
      • B cannot be redirected to any other address.
      • A cannot be redirected to A.

    There are two redirection methods:

    • Automatic redirection: you need to create an HTTPS:443 listener first and then create a forwarding rule under it. When you call this API, the system will automatically create an HTTP:80 listener (if it doesn't exist) and create a forwarding rule under it, which correspond to the various configurations under the HTTPS:443 listener, such as the domain name.
    • Manual redirection: you can manually configure the original access address and redirection address, and the system will automatically redirect requests made to the original access address to the destination address at the corresponding path. Multiple paths can be configured under the same domain name as a redirection policy to implement automatic redirection of requests between HTTP and HTTPS.

    Notes

    • If you don't have the TKE Ingress redirection annotation declaration, the original logic that doesn't manage redirection rules will be compatible; that is, you can configure redirection rules in the CLB console, and TKE Ingress doesn't process such rules.
    • If you don't have the TKE Ingress redirection annotation declaration, due to the redirection protection restrictions of CLB, if the forwarding configuration A is redirected to the forwarding configuration B, you must delete the redirection rule first before you can delete the forwarding configuration B.
    • If you use the TKE Ingress redirection annotation declaration, all redirection rules under CLB are managed by TKE Ingress and take effect only in the relevant annotations in TKE Ingress. In this case, if you modify the redirection configuration in the CLB console, the configuration will eventually be overwritten by the forwarding rule configured in TKE Ingress.

    Directions

    An Ingress supports two redirection configuration ways: console and YAML, as detailed below:

    1. Log in to the TKE console and select Cluster on the left sidebar.
    2. On the Cluster Management page, select the ID of the cluster for which to modify the Ingress.
    3. On the cluster details page, select Services and Routes > Ingress as shown below:
    4. Click Create and configure the relevant redirection rule on the Create Ingress page as shown below:
      • None: no redirection rules are used.
      • Manual: the Redirection Forwarding Configuration section will appear under Forwarding Configuration.
        • You can enter information in Forwarding Configuration just like for a general Ingress, with the backend being a certain service.
        • You can also enter information in Redirection Forwarding Configuration just like for a general Ingress, but the backend is a certain path in a certain "forwarding configuration".
      • Auto: it only takes effect for the "HTTPS" path in Forwarding Configuration. The same path with the "HTTP" protocol will be generated automatically, and only the protocols are different. The forwarding rule for the "HTTP" path is automatically redirected to the "HTTPS" path.