Bijlagen lokaal op de server, maar niet publiekelijk beschikbaar

Problem Summary

I’m encountering a 404 error when accessing an image upload via its URL on the live Discourse site (https://techenclave.com), even though the image is present on disk and served correctly internally. I’ve rebaked the post, restarted the app, and verified internal serving works, but it still 404s externally.


What’s Working

1. Upload Exists in DB

Using the Rails console, I confirmed that the upload exists with all correct metadata:

Upload.find_by(sha1: 'a8fbe877e685e6a6994532c946c446b1279da7d2')

Output includes:

  • url: "/uploads/default/original/3X/a/8/a8fbe877e685e6a6994532c946c446b1279da7d2.jpeg"
  • Filename: IMG202506252257011.jpg
  • ID: 170265
  • Used in Post ID: 3125774

2. File Exists on Disk

Verified file is present inside the container:

ls -l /shared/uploads/default/original/3X/a/8/a8fbe877e685e6a6994532c946c446b1279da7d2.jpeg

:check_mark: File exists with correct ownership and permissions:
discourse:www-data, -rw-r--r--.


3. Symlink from Public Folder Works

The public/uploads symlink is intact:

ls -l /var/www/discourse/public/uploads
# => /shared/uploads

4. Discourse Can Serve It Internally

Tested with:

curl -I http://localhost:3000/uploads/default/original/3X/a/8/a8fbe877e685e6a6994532c946c446b1279da7d2.jpeg

Result: HTTP/1.1 200 OK


5. Post Rebaked

Rebaked the post with:

Post.find(3125774).rebake!

6. App Restarted

Ran:

./launcher restart app

Also attempted:

sudo ./launcher rebuild app

(Docker daemon was temporarily unavailable but later fixed.)


What’s Not Working

External Access to Image

Accessing:

https://techenclave.com/uploads/default/original/3X/a/8/a8fbe877e685e6a6994532c946c446b1279da7d2.jpeg

Returns:

404 Not Found

This happens across browsers and in incognito mode.


What I Need Help With

Can someone help identify what could cause:

  • A working upload that serves via localhost:3000,
  • but returns 404 externally on the public domain?

What else should I check? Any related config or logs to inspect?

Thanks in advance!

Even freshly uploaded images are not loading. Getting 404

https://techenclave.com/uploads/default/original/3X/b/3/b38f7bc7a78e572cf46f092ab67837de6f648e46.png

Ik neem aan dat dit geen standaardinstallatie is? Dat is grotendeels alles wat hier wordt ondersteund.

Hoe heb je discourse geïnstalleerd?

1 like

Next time maybe mention that you very recently migrated?

Did you follow this guide when you changed from temp.techenclave.com to techenclave.com ?

2 likes

Bedankt.

De installatie was een standaard Discourse-installatiehandleiding op GitHub.

Ja, ik heb een lokale migratie uitgevoerd op mijn laptop, een back-up gemaakt en de back-up op de server hersteld door het bestand te uploaden en een back-upherstel uit het adminpaneel te doen. Had dat niet moeten doen, want niet alle bijlagen werden hersteld, ondanks dat het succesvol leek. Hoe dan ook, ik heb een rsync van bestanden van de lokale installatie op de laptop naar de server gedaan om ze up-to-date te krijgen.

Vervolgens was er een domeinmigratie, zoals u terecht opmerkte, van tijdelijk naar root na het testen van de setup voor een dag.

De reden dat ik het bovenstaande niet vermeldde, was omdat zelfs de nieuwste bestanden die na al deze activiteiten werden geüpload, ook niet worden weergegeven. Ondanks een rebuild. Dus ik vond die informatie niet relevant.

No did not follow that guide. But when I look at it I can see that only step missed was:

  1. The old domain shows up in allowed iframe list along with the new domain in settings.
  2. remapping domain in posts which I was going to do later anyway including a rebake once this issue is resolved. The post in question was rebaked and does not have the old domain in the URL of the image.

Are these two relevant points?

Even the theme image is giving a 404.

I see the nginx logs are littered with permission denied errors for images.

Plus I see this but unable to fix the permissions. Maybe I messed up some step like ran setup with wrong user.

root@ip-172-26-0-app:/var/www/discourse# ls -ld /shared/uploads/default/optimized/3X
drwx---r-x 18 discourse www-data 4096 Jun 29 17:52 /shared/uploads/default/optimized/3X
root@ip-172-26-0-app:/var/www/discourse# ls -ld /shared/uploads/default/optimized
drwx---r-x 5 discourse www-data 4096 Jun 29 17:52 /shared/uploads/default/optimized

Edit:
Fixed it by changing directory permissions and ownership.

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