Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

651
Views
¿Cómo configurar correctamente el caché de ingreso para que funcione?

Estoy tratando de configurar el caché para un host específico, pero obtengo 404. También parece que mi configuración no se incluyó en el nginx.conf final. Este archivo no lo contiene

Mi ingreso.yaml:

 apiVersion: extensions/v1beta1 kind: Ingress metadata: name: images-ingress labels: last_updated: "14940999355" annotations: kubernetes.io/ingress.class: "nginx" cert-manager.io/cluster-issuer: "letsencrypt-prod" nginx.ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/proxy-body-size: 8m nginx.ingress.kubernetes.io/proxy-buffering: "on" nginx.ingress.kubernetes.io/server-snippet: | proxy_cache static-cache; proxy_cache_valid 404 10m; proxy_cache_use_stale error timeout updating http_404 http_500 http_502 http_503 http_504; proxy_cache_bypass $http_x_purge; add_header X-Cache-Status $upstream_cache_status; spec: tls: - hosts: - static.qwstrs.com secretName: letsencrypt-prod rules: - host: static.qwstrs.com http: paths: - path: / backend: serviceName: imaginary servicePort: 9000

Si elimino esta muestra

 nginx.ingress.kubernetes.io/server-snippet: | proxy_cache static-cache; proxy_cache_valid 404 10m; proxy_cache_use_stale error timeout updating http_404 http_500 http_502 http_503 http_504; proxy_cache_bypass $http_x_purge; add_header X-Cache-Status $upstream_cache_status;

todo funciona pero sin cache

incluso si tengo una línea del fragmento anterior Produce un error 404 y no funciona

 nginx.ingress.kubernetes.io/server-snippet: | proxy_cache static-cache;
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Para habilitar el almacenamiento en caché, debe configurar proxy_cache_path para nginx-ingress-controller .
Puede hacerlo modificando el ConfigMap para nginx-ingress-controller .


Creé un ejemplo para ilustrar cómo funciona (supongo que tiene kubernetes/ingress-nginx ).

Primero, cree un ConfigMap llamado ingress-nginx-controller como se describe en la documentación custom_configuration :
Nota: Es posible que deba modificar la configuración de proxy_cache_path , pero la zona de memoria compartida (keys_zone= static-cache ) debe ser la misma que en su directiva proxy_cache .

 $ cat configmap.yml # configmap.yaml apiVersion: v1 kind: ConfigMap metadata: name: ingress-nginx-controller namespace: default data: http-snippet: "proxy_cache_path /tmp/nginx_cache levels=1:2 keys_zone=static-cache:10m max_size=10g inactive=60m use_temp_path=off;" $ kubectl apply -f configmap.yml configmap/ingress-nginx-controller configured

Y luego cree el Ingress de ingreso (he modificado un poco su recurso de ingreso para demostrar cómo funciona el encabezado X-Cache-Status ):

 $ cat ingress.yml apiVersion: extensions/v1beta1 kind: Ingress metadata: name: images-ingress annotations: kubernetes.io/ingress.class: "nginx" nginx.ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/proxy-body-size: 8m nginx.ingress.kubernetes.io/proxy-buffering: "on" nginx.ingress.kubernetes.io/configuration-snippet: | proxy_cache static-cache; proxy_cache_valid any 60m; add_header X-Cache-Status $upstream_cache_status; spec: tls: - hosts: - static.qwstrs.com secretName: letsencrypt-prod rules: - host: static.qwstrs.com http: paths: - path: / backend: serviceName: imaginary servicePort: 9000 $ kubectl apply -f ingress.yml ingress.extensions/images-ingress configured

Finalmente podemos comprobar:

 $ curl -k -I https://static.qwstrs.com HTTP/2 200 ... x-cache-status: MISS accept-ranges: bytes $ curl -k -I https://static.qwstrs.com HTTP/2 200 ... x-cache-status: HIT accept-ranges: bytes

Puede encontrar más información sobre proxy_cache_path y proxy_cache aquí .

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!