I got activestorage to work with my rails 5.2 app on localhost.
class Course < ApplicationRecord
has_many_attached :files
I'm using direct-upload and storing to local storage. But when I deploy to the staging server I hit two problems:
Upload is broken
Of the three HTTP requests needed to upload a file:
- POST /rails/active_storage/direct_uploads HTTP/1.1
- PUT /rails/active_storage/disk/eyJfcmFpbHMi...3aff HTTP/1.1
- POST /course/1908/file_update HTTP/1.1
the second request never get's a response. The response should be a simple 204 No Content, but instead it runs into a timeout.
the server setup is:
- nginx revers proxy on on machine calls
- apache on another machine, which runs
- passenger
I can see in the logfile that rails writes that the response for the second request is actually quite fast:
Started PUT "/rails/active_storage/disk/eyJfcmFpbHMi...
...
Disk Storage (0.8ms) Uploaded file to key: 82L8qxveeux.. (checksum: ..J1BK==)
Completed 204 No Content in 2ms (ActiveRecord: 0.0ms)
Download is broken
When I attache a file to a course via the rails console, and then try to download the file, I recieve an empty file with the right filename.
Again, the rails logfile seems ok:
Started GET "/rails/active_storage/disk/eyJfcmFpbHMiOn....
...
Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
but somewhere between nginx, apache and passenger the body of the response is lost.
Any ideas what could be at fault here?