Can someone help me understand how uploading images work?

I’m running diaspora on @koehn’s docker image and I’m having a weird issue with uploads that I can’t understand, but I have essentially no knowledge of how the process works.

Right now, my public/uploads folder is mounted as a managed docker volume. I don’t know why I did this originally, I want it to be a normal docker volume mounted to my config directory. This will make the directory easier to back up.

When I change volumes, uploading no longer works, I get a 500 - Internal Server Error.

As far as I can tell, the process is transparent. I have copied all the old images from the old volume to the new one, and they still show up just fine. I double checked that they’re not cached, if I remove them from the new volume they stop showing up. So the diaspora app is accessing the uploads directory the same as it always does.

What in the world could be causing this? The only thing I can think of is that maybe nginx is getting in the way? My nginx config doesn’t reference a particular path at all, it just routes the HTTPS traffic to the server port.

I’ve had issues with nginx before though. For example, I can’t serve any files directly, I have to serve them through the webserver. So I’m betting that this could be the problem.

I can’t find any logs to help me out. The diaspora logs don’t show any activity when I try to upload a file and get an error. I’m not sure how to get the nginx logs.

Does anyone have advice that might help me track down the error?

You can set the environment variable RAILS_SERVE_STATIC_FILES to true to enable serving static files.

The comment here might be helpful as well. diaspora/production.rb at develop · diaspora/diaspora · GitHub

1 Like

I could imagine the new volume no longer has write permissions or something.

Whenever seeing an 500 you should check log/production.log for the real error :slight_smile:

1 Like

I will try that. I do use nginx though, so I shouldn’t have to do that. It would be nicer for nginx to manage it. Thank you!

[2021-05-31T16:45:07] INFO  PID-349 TID-70305654274420 ActionController::Base: Completed 500 Internal Server Error in 63ms (ActiveRecord: 0.6ms)
[2021-05-31T16:45:07] FATAL PID-349 TID-70305654274420 Rails:   
[2021-05-31T16:45:07] FATAL PID-349 TID-70305654274420 Rails: Errno::EACCES (Permission denied @ rb_sysopen - /home/diaspora/diaspora/public/uploads/images/5d0a25103239c35c06be.jpg):

You were right, looks like it can’t access it. The directory was owned by root! Whoops.

I think it’s fixed now. I can upload images and all my old images are still there. Everything appears to work. Thank you so much!

Also, now I know where to go for logs. I think I will be able to solve future problems much more quickly. Thank you for that too!

1 Like

I think I found my problem. I need the entire public directory to be mounted on my host, otherwise nginx can’t find everything it needs like CSS files. I turned off the setting to serve the static files through the app server and everything still loads and looks fine.

Thank you for the help!