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

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