Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
El almacenamiento en caché de Nginx de uwsgi sirvió archivos estáticos

El proyecto django se implementa usando uwsgi como servidor de aplicaciones, también sirve archivos estáticos desde un directorio específico (como se muestra en el siguiente comando) y nginx se usa como servidor proxy inverso. Esto se implementa usando docker.

El comando uwsgi para ejecutar el servidor es el siguiente:

uwsgi -b 65535 --socket :4000 --workers 100 --cpu-affinity 1 --module wui.wsgi --py-autoreload 1 --static-map /static=/project/static;

La aplicación está funcionando bien en este punto. Me gustaría almacenar en caché los archivos estáticos en el servidor nginx. Así que me he referido al blog https://www.nginx.com/blog/maximizing-python-performance-with-nginx-parti-web-serving-and-caching y he incluido la siguiente configuración en mi nginx.conf:

 location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg |jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid |midi|wav|bmp|rtf)$ { expires max; log_not_found off; access_log off; }

Después de agregar esto a mi conf Nginx, el contenedor del servidor Nginx sale con el siguiente error:

[emerg] 1#1: invalid number of arguments in "location" directive in /etc/nginx/nginx.conf:43

¿Es así como los archivos estáticos servidos por uwsgi se pueden almacenar en caché en nginx? En caso afirmativo, sugiérame qué salió mal aquí.

Mi nginx.conf completo es el siguiente:

 events { worker_connections 1024; ## Default: 1024 } http { include conf/mime.types; # the upstream component nginx needs to connect to upstream uwsgi { server backend:4000; # for a web port socket (we'll use this first) } # configuration of the server server { # the port your site will be served on listen 8443 ssl http2 default_server; # the domain name it will serve for server_name _; # substitute your machine's IP address or FQDN charset utf-8; ssl_certificate /secrets/server.crt; ssl_certificate_key /secrets/server.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; add_header Strict-Transport-Security "max-age=31536000" always; # Redirect HTTP to HTTPS error_page 497 https://$http_host$request_uri; # max upload size client_max_body_size 75M; # adjust to taste uwsgi_read_timeout 600s; # Finally, send all non-media requests to the Django server. location / { uwsgi_pass uwsgi; include /config/uwsgi_params; # the uwsgi_params file you installed } location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg |jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid |midi|wav|bmp|rtf)$ { expires max; log_not_found off; access_log off; } } }

Versión de Nginx: 1.16

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

El problema con su configuración es que el bloque de ubicación tiene líneas nuevas en la lista de nombres de archivo. nginx -t -c <filename> con una versión modificada de su bloque de ubicación:

 location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { expires max; log_not_found off; access_log off; }

... y esto pasa la prueba!

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda