I have a problem with Kubernetes deployment. My service works perfectly when accessing "example.com" or "https://example.com" but it does not work when accessing over "www.example.com" or "http://example.com" the default nginx backend shows up with a 404.
Here is my ingress implementation:
# Ingress
apiVersion: networking.k8s.io/v1
# make a new cert
kind: Ingress
metadata:
name: ${APP_NAME}
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
tls:
- secretName: ${APP_NAME}
hosts:
- ${URL}
- www.${URL}
rules:
- host: ${URL}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: ${APP_NAME}
port:
number: 80
here is my certificate it should be fine with both domains:
# Certificate
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: ${APP_NAME}
spec:
secretName: ${APP_NAME}
dnsNames:
- example.com
- www.example.com
issuerRef:
name: letsencrypt-production
# We can reference ClusterIssuers by changing the kind here.
# The default value is Issuer (i.e. a locally namespaced Issuer)
kind: ClusterIssuer
group: cert-manager.io