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

304
Views
Rails NGINX ActiveStorage 404 no encontrado

Actualmente, acabo de implementar mi aplicación en producción con Docker; todo parece funcionar bien, solo que no se muestran los archivos adjuntos.

Para mostrar una imagen, uso una image_tag donde el atributo src es el enlace ActiveStorage correspondiente para mi almacenamiento (local):

 <%= image_tag(rails_blob_path(examination.png_file), ... %>

Mi storage.yml se ve así, nada especial aquí:

 local: service: Disk root: <%= Rails.root.join("tmp/storage") %> test: service: Disk root: <%= Rails.root.join("tmp/storage") %>

nginx.conf:

 upstream app { server 'app:3000'; } server { listen 80; server_name localhost; keepalive_timeout 5; proxy_http_version 1.1; # path for static files root /app/public; access_log /app/log/nginx.access.log; error_log /app/log/nginx.error.log info; location / { try_files $uri @app; } location /cable { proxy_http_version 1.1; proxy_pass http://app; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header X-Real-IP $remote_addr; } location @app { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_pass http://app; proxy_headers_hash_max_size 512; proxy_headers_hash_bucket_size 128; proxy_buffering off; proxy_request_buffering off; } location ~ \.(png|jpg|jpeg|gif|ico|html|woff|woff2|ttf|svg|eot|otf|pdf)$ { gzip_static on; gzip on; gzip_comp_level 6; gzip_buffers 16 8k; gzip_vary on; gzip_proxied any; expires max; access_log off; add_header Cache-Control public; add_header Access-Control-Allow-Origin *; } location = /500.html { root /app/current/public; } }

El registro de errores de nginx dice que no se encuentra el archivo:

2021/07/05 08:58:28 [error] 30#30: *5 open() "/app/public/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBDUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--c029e64b796958796958f106756ed1e3546c7c4e568c58/0ZVX341F.dcm.png" failed (2 : El fichero o directorio no existe)

No sé si la app/public antes de /rails es el problema, pero ¿cómo puedo deshacerme de él en esta URL? Supongo que proviene de la directiva raíz para nginx.

¡Gracias por cada idea y ayuda!

máx.

over 4 years ago · Santiago Trujillo
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!