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

309
Vistas
Rails NGINX ActiveStorage 404 Not Found

Currently I just deployed my application to production with Docker - everything seems to work fine, just the attachments are not displayed.

To display an image, I use an image_tag where the src attribute is the according ActiveStorage link for my (local) storage:

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

My storage.yml looks like this, nothing special here:

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;
  }
}

The nginx error log says that the file is not found:

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: No such file or directory)

I don't know if the app/public before the /rails is the problem, but how can I get rid of it in this URL? It's coming from the root directive for nginx I guess.

Thanks for every idea and help!

Max

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