Images not loading (404)


#1

On my instance images are not loading. In browser console I get 404 errors for them. If I open them on the “real” remote instance they are available.

If I try to upload images and toot them, they upload without any error but are also broken and not shown. The error log from apache does not show any entry.
To my config: I have three virtual machines, one for the database(postgres), one for mastodon itself and one for the webserver (apache2). Mastodon is up to date and ruby is v2.5.3.

I copied the /home/mastodon/live/public folder to the webserver vm and set this folder as document root.

Apache2 Virtual Host
<IfModule mod_ssl.c>
<VirtualHost *:443>
   ServerAdmin support@domain.tld
   ServerName social.domain.tld

   DocumentRoot /var/www/mastodon_pub

   ErrorLog /var/log/apache2/social.domain.tld/error.log
#   CustomLog /var/log/apache2/social.domain.tld/access.log null
   CustomLog /dev/null null

   Header always set Referrer-Policy "strict-origin-when-cross-origin"
   Header always set Strict-Transport-Security "max-age=31536000"

   SSLEngine on
   SSLProtocol -all +TLSv1.2
   SSLHonorCipherOrder on
   SSLCipherSuite EECDH+AESGCM:AES256+EECDH:AES128+EECDH
   SSLCompression off
   SSLSessionTickets off
#   SSLStaplingResponderTimeout 5
#   SSLStaplingReturnResponderErrors off
#   SSLUseStapling on

   SSLCertificateFile /etc/letsencrypt/live/social.domain.tld/fullchain.pem
   SSLCertificateKeyFile /etc/letsencrypt/live/social.domain.tld/privkey.pem
   SSLCertificateChainFile /etc/letsencrypt/live/social.domain.tld/chain.pem

   <LocationMatch "^/(assets|avatars|emoji|headers|packs|sounds|system)>
      Header always set Cache-Control "public, max-age=31536000, immutable"
      Require all granted
   </LocationMatch>

   ProxyPreserveHost On
   RequestHeader set X-Forwarded-Proto "https"

   ProxyPass /500.html !
   ProxyPass /sw.js !
   ProxyPass /robots.txt !
   ProxyPass /manifest.json !
   ProxyPass /browserconfig.xml !
   ProxyPass /mask-icon.svg !
   ProxyPassMatch ^(/.*\.(png|ico)$) !
   ProxyPassMatch ^/(assets|avatars|emoji|headers|packs|sounds|system|.well-known/acme-challenge) !

   ProxyPass /api/v1/streaming/ ws://172.16.5.3:4000/
   ProxyPassReverse /api/v1/streaming/ ws://172.16.5.3:4000/
   ProxyPass / http://172.16.5.3:3000/
   ProxyPassReverse / http://172.16.5.3:3000/

   ErrorDocument 500 /500.html
   ErrorDocument 501 /500.html
   ErrorDocument 502 /500.html
   ErrorDocument 503 /500.html
   ErrorDocument 504 /500.html
</VirtualHost>
</IfModule>

For example “https://social.domain.tld/system/media_attachments/files/000/014/399/small/8d044847d0785542.jpeg?1546732195” ends in an 404. Most of the profile pictures are loading but not all.

I already tried to rebuild (like described on new version in github) and did bundle and yarn install. Reboot of mastodon vm did not helped either.


#3

Mastodon uploads images to the public/system/ folder, so “copying” is obviously not going to work—how do you expect new image uploads to make their way to the webserver VM?

This configuration you describe doesn’t sound at all like the recommended configuration, so I don’t think I can be of much more help in debugging it—I would recommend you take a look at the Installation Guide and follow the steps closely.


#4

Thanks for the information. Mounting the public folder in webserver vm creates a lot of issues, sad. I created this setup as I do not want to waste ip addresses nor do I want mastodon on my webserver machine. Will do it with a new ipv4 now, thank you.


#5

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.