If you’re using Strapi and you’re trying to figure out how to setup Nginx Ingress for Kubernetes or you are trying to solve one of the following issues:
– https://github.com/strapi/strapi/issues/3462
– https://github.com/strapi/strapi/issues/2424
Here’s the ingress configuration, and your nginx ingress helm chart value you should be editing:
#1 Provide use-forwarded-headers in your helm chart’s controller config params
# values.yaml controller: config: use-forwarded-headers: "true"
#2 My ingress config
apiVersion: extensions/v1beta1 kind: Ingress metadata: annotations: nginx.ingress.kubernetes.io/use-regex: "true" nginx.ingress.kubernetes.io/proxy-body-size: 200m nginx.ingress.kubernetes.io/enable-cors: "true" nginx.ingress.kubernetes.io/cors-allow-origin: "*" nginx.ingress.kubernetes.io/cors-allow-headers: "*" nginx.ingress.kubernetes.io/cors-allow-credentials: "true" nginx.ingress.kubernetes.io/cors-allow-methods: "*" nginx.ingress.kubernetes.io/proxy-connect-timeout: "30s" nginx.ingress.kubernetes.io/proxy-read-timeout: "20s" nginx.ingress.kubernetes.io/client-body-buffer-size: "50m" kubernetes.io/ingress.class: nginx name: strapi-ingress spec: rules: - host: mydomain.com http: paths: - path: / backend: serviceName: angular-ui servicePort: 80 # Depends on the plugins you use - path: /(admin|plugins|email|settings-manager|documentation|content-type-builder|upload|users-permissions|users|content-manager|auth)/?.*$ backend: serviceName: strapi servicePort: 1337
#3 Custom nginx ingress installation
You might want to create a custom configmap to us within your nginx ingress installation like the following:
apiVersion: v1 data: use-forwarded-headers: "true" kind: ConfigMap metadata: name: nginx-configuration
#4 Digital Ocean k8s
or if you are running your k8s in Digital Ocean you need to add few more config params, but I’d suggest you read this full blog post:
#5 Nginx map directive
If you are simply using Nginx as a load balancer, you might want to setup the map directive outside your server block like the solution provided in this comment: https://github.com/strapi/strapi/issues/2424#issuecomment-445964719