<p>I've set up and NGINX Ingress on Azure Kubernetes with an annotation to redirect from example.com to <a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a>.</p>

<p>The current configuration used to work perfectly but no longer works.
Configuration is as follows:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: myapp-ingress
  annotations:
    nginx.ingress.kubernetes.io/configuration-snippet: |
      if ($host = 'example.com' ) {
        rewrite ^ https://www.example.com$request_uri permanent;
      }
    nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
spec:
  tls:
    - hosts:
      - example.com
      - www.example.com
      secretName: myapp-secret
  rules:
  - host: www.example.com
    http:
      paths:
      - backend:
          serviceName: myapp-prod-service
          servicePort: 80
  - host: domain.com
    http:
      paths:
      - backend:
          serviceName: myapp-prod-service
          servicePort: 80
</code></pre>

Ben Gannaway
<p>This only wasn't working because of the internal network setup where I was working. The configuration above is correct and works. </p>
