Skip to content

How to https redirect naked domain to www using from-to-www-redirect  #5675

@Janaka-Steph

Description

@Janaka-Steph

Hello,

I am not sure if it is a bug, but still I can't https redirect naked domain to www subdomain using from-to-www-redirect annotation. I did lot of tests checking the ingress-controller logs and resulted Nginx config, and I will show you what is going on. AFAIK I need one server block for naked domain and one for www subdomain in order to handle SSL handshake.


  1. I create a block for example.com
    Block example.com created without redirection.
  2. I try to create a block for www.example.com with from-to-www-redirect
    Logs says: Already exists an Ingress with "example.com" hostname. Skipping creation of redirection from "example.com" to "www.example.com".
    Block www.example.com created without redirection.


// Not what I want because would redirect to naked but attempted anyway

  1. I create a block for www.example.com
    Block www.example.com created without redirection.
  2. I try to create a block for example.com with from-to-www-redirect
    Logs says: Already exists an Ingress with "www.example.com" hostname. Skipping creation of redirection from "www.example.com" to "example.com".
    Block example.com created without redirection.


  1. I create a block for www.example.com with from-to-www-redirect
    Logs: the server example.com has SSL configured but the SSL certificate does not contains a CN for www.example.com. Redirects will not work for HTTPS to HTTPS
    Redirect block "server_name example.com" added to nginx.conf
  2. I create a block for example.com without from-to-www-redirect
    Logs: Already exists an Ingress with "example.com" hostname. Skipping creation of redirection from "example.com" to "www.example.com"
    Redirect block is removed from nginx conf!


// Not what I want because would redirect to naked but attempted anyway

  1. I create a block for example.com with from-to-www-redirect
    Logs: the server www.example.com has SSL configured but the SSL certificate does not contains a CN for example.com. Redirects will not work for HTTPS to HTTPS
    Redirect block is added to nginx.conf
  2. I create a block for www.example.com without from-to-www-redirect
    Logs: Already exists an Ingress with "www.example.com" hostname. Skipping creation of redirection from "www.example.com" to "example.com".
    Redirect block is removed from nginx conf!


  1. I create a block for www.example.com with from-to-www-redirect
    Logs the server example.com has SSL configured but the SSL certificate does not contains a CN for www.example.com. Redirects will not work for HTTPS to HTTPS
    Redirect block "server_name example.com" added to nginx.conf
  2. I create a block for example.com with from-to-www-redirect
    Logs:
  • Already exists an Ingress with "www.example.com" hostname. Skipping creation of redirection from "www.example.com" to "example.com".
  • Already exists an Ingress with "example.com" hostname. Skipping creation of redirection from "example.com" to "www.example.com".
    Redirect blocks are removed from nginx conf!

So the next question is, what am I doing wrong and how people normally do HTTPS to HTTPS redirection?! I can't be the first person to came across this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/supportCategorizes issue or PR as a support question.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions