I'm running a Django app over DigitalOcean's Kubernetes, the site runs over https
but when I try to use the Django Admin from the domain, it throws a 403 forbidden error but if I connect directly to the Pod it succeeds. I wondered if it has to do with the ingress
set up that is not recognizing the paths of api.example.com
.
Here's the ingress.yaml
file
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: backend-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
ingressClassName: nginx
tls:
- hosts:
- example.com
- api.example.com
secretName: tls-secret-name
rules:
- host: api.example.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: backend
port:
number: 8000
- host: example.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: frontend
port:
number: 3000
Any clue?
If anyone has the same problem. The solution since Django 4.2, is setting SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
on your setting.py
file