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

160
Views
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 answers
Answer question

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 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!