Docker First Time Setup gives 404 on all /ghost/assets/

TLDR:
I get 404 on /ghost/assets/* in the First Time Setup after clean Docker Install
only /var/lib/ghost/content is mounted, so the /assets/ files should exist self-contained within the docker image. Why are they not present?


Heya, I’m trying to set up Ghost on Unraid (for the 3rd time actually :) )
I had it semi-working before but Ghost didn’t generate resized images and showed 404s for them instead and the linked ‘content’ folder didn’t have any of the recently uploaded images in it at all (they also weren’t in the in-memory container … weird stuff!)

Anyway, my issue is that I now did a completely fresh setup after completely wiping both content, appdata, database and previous container image. I can access the /ghost page and could create my user. On the Let’s get started! page it then already fails on the 2nd entry (Customize your design) which fails to load a module. Most of the /ghost/assets/* files seem to 404. How come? These files are, from what I understand, part of the Ghost docker image itself which is, by default, not mounted as a volume so it cannot (should not) be a permission issue.
I know the info and problem is likely very broad, but I hope we can pick at one thing at a time to get it working.

Bonus question:
In other forum posts I heard mentions of ‘package.json’ and being able to edit HTML directly in specific files. The only place I could find package.json is the container image itself and when attempting to mount the Theme(s) folder externally, it doesn’t work because its contents are symlinks. Has this been successfully done via Docker install before?

What’s your URL?
I’ll provide once it’s useful. It fails in the admin panel already

What version of Ghost are you using?
5.82.11

How was Ghost installed and configured?

Container IP 172.18.0.25

url:https://www.example.com

database__client:mysql
database__connection__host:173.18.0.3
database__connection__port:3306
database__connection__user:ghost
database__connection__password:not1234
database__connection__database:ghost

mail__transport:SMTP
mail__options__service:
mail__options__auth__user:webmaster@example.com
mail__options__auth__pass:not1234
mail__options__host:smtp.gmail.com
mail__options__port:587
mail__from:'Name' <webmaster@example.com>

/var/lib/ghost/content -> /mnt/user/ghost/example

What Node version, database, OS & browser are you using?

  • If my install uses Node it must be bundled
  • DB is mariadb 11.3.2
  • OS of host is Unraid 6.12.10 , Client is Windows 11 (22631)
  • Browser is Chrome 125.0.6422.78

What errors or information do you see in the console?

Chrome
Failed to load resource: the server responded with a status of 403 () ghost/api/admin/users/me/?include=roles:1
Failed to load resource: the server responded with a status of 404 () ghost/assets/admin-x-settings/modals-ae924d1e.mjs:1
Uncaught (in promise) TypeError: Failed to fetch dynamically imported module: https://example.com/ghost/assets/admin-x-settings/modals-ae924d1e.mjs
Docker:
[2024-05-24 22:18:15] INFO "GET /ghost/api/admin/newsletters/?include=count.active_members%2Ccount.posts&limit=50" 200 29ms
[2024-05-24 22:18:15] INFO "GET /ghost/api/admin/integrations/?include=api_keys%2Cwebhooks" 200 36ms
[2024-05-24 22:18:24] INFO "GET /ghost/assets/vendor-c767bea8e64198534441e9cbd3fce355.map" 404 5ms
[2024-05-24 22:18:24] INFO "GET /ghost/assets/chunk.524.712c85d7aae3325b5222.map" 404 15ms
[2024-05-24 22:18:24] INFO "GET /ghost/assets/chunk.799.4deb46f52edfd88977f5.map" 404 17ms
[2024-05-24 22:18:24] INFO "GET /ghost/assets/ghost-fc1f02c2f5616859eca1ee4cdba068b8.map" 404 19ms
[2024-05-24 22:18:24] INFO "GET /ghost/assets/admin-x-settings/index-8d67ef5d.mjs.map" 404 22ms

What steps could someone else take to reproduce the issue you’re having?
Install docker via Unraid out of the box, navigate to the /ghost website, create admin account in setup screen and click on the 2nd entry “Customize your design”

My docker-compose file is available at #1 GhostCMS - Installation Docker
Try to read the content and adjust the files needed to run according to your needs.

Thanks for the reply and the suggested docker file; however, I’m not looking for a CMS system for Ghost at this time and the content that’s not loading isn’t assets from me - it’s the official docker’s internal files that fail loading and I’m looking for a solution to that. :slight_smile:

Resolved:
The issue was caused by cloudflare caching because I did a clean install and parts of the old installation remained in cache.


I did get a bit further as today it appears to be showing something when I click “Customize your design” where yesterday it just showed a blurred background without a panel opening.

Yesterday:

Today:

That gave me the hunch that this may be caching related, so I added a cloudflare cache rule for ‘/ghost’ in the hopes that this may help.

Lastly, given the (redacted) CORS header errors it was trying to access www.example.com from example.com. For this adding a naked redirect to www.example.com (either in cloudflare or nginx - I chose cloudflare) worked just fine. The process for cloudflare is outlined here if you need it, given that page rules are now deprecated.
https://community.cloudflare.com/t/redirect-rules-cheat-sheet/508780

And with that, the admin panel is accessible as it should be:

You might also want to add the /member route as an exceptions.

Tested this with BunnyCDN, but I would assume it would work with Cloudflare as well.

As an alternative, @smartgoat has an interesting approach in his blog post about BunnyCDN: exceptions based on the *ghost-members-ssr* and *admin-api-session* cookies. Not sure if that works with Cloudflare, but it’s the most elegant solution to me right now.

1 Like

Yes the cookie based approach also works with cloudflare. Here is the full guide about that How to Optimize Cloudflare Caching for Blazing Fast Ghost Blog.

The only 3 reasons to go with bunny are:

  1. They have good support.
  2. Better routing even when not caching (More noticeable in APAC region).
  3. Longer cache retention. Cloudflare aggressively purges cache, so if you have low traffic, then chances of hitting cache are higher with bunny.
2 Likes

Thanks for the tips you two. :smile: I’ll add /member to the exceptions for now and look into using cookies for this instead as per smartgoat’s guide.

However, switching to BunnyCDN isn’t something I’d want to do or consider as I’m quite happy with what Cloudflare can do on it’s free tier (and that it’s super stable and widely used, so you find plenty of help online). I don’t expect much traffic on my blog.

1 Like

Yeah, never meant to push you to BunnyCDN – just wanted to point out that there are additional exceptions that might be useful :smiley: