Cannot see uploaded image #3792

Closed
opened 2026-02-05 07:29:23 +03:00 by OVERLORD · 10 comments
Owner

Originally created by @jacobolsen-vse on GitHub (May 10, 2023).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

When the storage type is set to secure or secure restricted I cannot see the images I upload to a page.

Steps to reproduce:

  1. Edit a page
  2. Click on insert image
  3. Click on "click here to upload image" and select an image
  4. The image loads and a notification appears saying "Image uploaded successfully"
  5. But then a grey "x" is shown for the image thumbnail and when the image is selected to insert into the page it does not show either

bookstack image gallery

And the page looks like this:

bookstack page example

Permissions:

bookstack storage permissions
bookstack gallery permissions

Exact BookStack Version

v23.02.3

Log Content

nginx error.log exerpt:

2023/05/09 17:33:08 [error] 4535#4535: *62 open() "/var/www/bookstack/public/uploads/images/gallery/2023-05/thumbs-150-150/dNBkqkCBjt0vs9a4-orem-office-cropped.jpg" failed (2: No such file or directory), client: client ip, server: my site, request: "GET /uploads/images/gallery/2023-05/thumbs-150-150/dNBkqkCBjt0vs9a4-orem-office-cropped.jpg HTTP/1.1", host: "my site", referrer: "https:// my site/books/administrative-links/draft/4266"

PHP Version

8.1.2

Hosting Environment and additional context:

  • Ubuntu 22.04.2 LTS
  • Nginx 1.18
  • Installed manually via the installation guide on BookStack site
  • Running composer install has no errors
  • There are nothing logged in my laravel.log when this error occurs
  • Uploading an image absolutely works when storage type is set to local, but I need the images to be secure.

nginx server block configuration for bookstack:

Details

server {

        root /var/www/bookstack/public;
        index index.php index.html;

        server_name my.site.com;

        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
        }

        location ~ /\.ht {
            deny all;
        }

        location /uploads {
            autoindex off;
        }

        listen [::]:443 ssl ipv6only=on; # managed by Certbot
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/my.site.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/my.site.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {

        if ($host = my.site.com) {
            return 301 https://$host$request_uri;
        } # managed by Certbot


        listen 80;
        listen [::]:80;

        server_name my.site.com;
        return 404; # managed by Certbot

}

Originally created by @jacobolsen-vse on GitHub (May 10, 2023). ### Attempted Debugging - [X] I have read the debugging page ### Searched GitHub Issues - [X] I have searched GitHub for the issue. ### Describe the Scenario When the storage type is set to secure or secure restricted I cannot see the images I upload to a page. ### Steps to reproduce: 1. Edit a page 2. Click on insert image 3. Click on "click here to upload image" and select an image 5. The image loads and a notification appears saying "Image uploaded successfully" 6. But then a grey "x" is shown for the image thumbnail and when the image is selected to insert into the page it does not show either #### For example the gallery looks like this: ![bookstack image gallery](https://github.com/BookStackApp/BookStack/assets/123602423/903652ea-2615-47b5-895e-f6a2360caf83) #### And the page looks like this: ![bookstack page example](https://github.com/BookStackApp/BookStack/assets/123602423/ab36e7ba-f2ef-4c77-bb59-89389fed823f) ### Permissions: ![bookstack storage permissions](https://github.com/BookStackApp/BookStack/assets/123602423/516f99e0-2201-4ac1-9922-66cb703cecb0) ![bookstack gallery permissions](https://github.com/BookStackApp/BookStack/assets/123602423/337ed031-aab1-42e0-8d60-610cd9fb5742) ### Exact BookStack Version v23.02.3 ### Log Content **nginx error.log exerpt:** 2023/05/09 17:33:08 [error] 4535#4535: *62 open() "/var/www/bookstack/public/uploads/images/gallery/2023-05/thumbs-150-150/dNBkqkCBjt0vs9a4-orem-office-cropped.jpg" failed (2: No such file or directory), client: client ip, server: my site, request: "GET /uploads/images/gallery/2023-05/thumbs-150-150/dNBkqkCBjt0vs9a4-orem-office-cropped.jpg HTTP/1.1", host: "my site", referrer: "https:// my site/books/administrative-links/draft/4266" ### PHP Version 8.1.2 ### Hosting Environment and additional context: - Ubuntu 22.04.2 LTS - Nginx 1.18 - Installed manually via the installation guide on BookStack site - Running composer install has no errors - There are nothing logged in my laravel.log when this error occurs - Uploading an image absolutely works when storage type is set to local, but I need the images to be secure. ### nginx server block configuration for bookstack: <details><summary>Details</summary> <p> ``` server { root /var/www/bookstack/public; index index.php index.html; server_name my.site.com; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; } location ~ /\.ht { deny all; } location /uploads { autoindex off; } listen [::]:443 ssl ipv6only=on; # managed by Certbot listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/my.site.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/my.site.com/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { if ($host = my.site.com) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; listen [::]:80; server_name my.site.com; return 404; # managed by Certbot } ``` </p> </details>
OVERLORD added the 🐕 Support label 2026-02-05 07:29:23 +03:00
Author
Owner

@ssddanbrown commented on GitHub (May 10, 2023):

Hi @jacobolsen-vse,

Can you provide the exact output of running:

ls -alh /var/www/bookstack/storage/uploads/images/gallery/2023-05/thumbs-150-150

and:

ls -alh /var/www/bookstack/storage/uploads/images/gallery/2023-05
@ssddanbrown commented on GitHub (May 10, 2023): Hi @jacobolsen-vse, Can you provide the exact output of running: ```bash ls -alh /var/www/bookstack/storage/uploads/images/gallery/2023-05/thumbs-150-150 ``` and: ```bash ls -alh /var/www/bookstack/storage/uploads/images/gallery/2023-05 ```
Author
Owner

@jacobolsen-vse commented on GitHub (May 10, 2023):

Thank you for the quick response.
The output is as follows. I've marked the image from the example I posted.
bookstack thumbnail snip
bookstack 2023-05 snip

@jacobolsen-vse commented on GitHub (May 10, 2023): Thank you for the quick response. The output is as follows. I've marked the image from the example I posted. ![bookstack thumbnail snip](https://github.com/BookStackApp/BookStack/assets/123602423/93f7b328-f7bb-4c26-bdc6-9debf5664fa5) ![bookstack 2023-05 snip](https://github.com/BookStackApp/BookStack/assets/123602423/1b48bb12-9109-429c-b0ab-81aa8e59b928)
Author
Owner

@ssddanbrown commented on GitHub (May 10, 2023):

@jacobolsen-vse Thanks, can you screenshot exactly what the screen looks like when you attempt to navigate to one of these image URLs? (Should maybe be able to click through after saving a page with a broken image in, or view the editor HTML (button in right of toolbar) and grab the link from the code).

@ssddanbrown commented on GitHub (May 10, 2023): @jacobolsen-vse Thanks, can you screenshot exactly what the screen looks like when you attempt to navigate to one of these image URLs? (Should maybe be able to click through after saving a page with a broken image in, or view the editor HTML (button in right of toolbar) and grab the link from the code).
Author
Owner

@jacobolsen-vse commented on GitHub (May 10, 2023):

@ssddanbrown
bookstack image url example

@jacobolsen-vse commented on GitHub (May 10, 2023): @ssddanbrown ![bookstack image url example](https://github.com/BookStackApp/BookStack/assets/123602423/d3fa454a-ff98-43f7-847f-6916e15c7525)
Author
Owner

@lommes commented on GitHub (May 10, 2023):

Is the directory uploads correctly symlinked to public/uploads ? You can check this with
ls -lah /var/www/bookstack/public/

@lommes commented on GitHub (May 10, 2023): Is the directory uploads correctly symlinked to public/uploads ? You can check this with `ls -lah /var/www/bookstack/public/`
Author
Owner

@ssddanbrown commented on GitHub (May 10, 2023):

@lommes We don't do symlinky stuff in BookStack.

The request should be falling back to the app on non-existing images but I don't feel that's happening based on the nginx 404 view. Will need to double check this on my dev machine on nginx when I get a moment.

@ssddanbrown commented on GitHub (May 10, 2023): @lommes We don't do symlinky stuff in BookStack. The request should be falling back to the app on non-existing images but I don't feel that's happening based on the nginx 404 view. Will need to double check this on my dev machine on nginx when I get a moment.
Author
Owner

@lommes commented on GitHub (May 10, 2023):

Sorry for causing confusion. In my setup I automatically deploy using some files and folders as symlinks throughout multiple versions and thought one of them was the result of the default storage:link command.

@lommes commented on GitHub (May 10, 2023): Sorry for causing confusion. In my setup I automatically deploy using some files and folders as symlinks throughout multiple versions and thought one of them was the result of the default storage:link command.
Author
Owner

@jacobolsen-vse commented on GitHub (May 12, 2023):

Hi @ssddanbrown,

I'm still unable to get uploading images to work. Can I provide you with any more info on my environment or do you have any suggestions on how I can fix this?

@jacobolsen-vse commented on GitHub (May 12, 2023): Hi @ssddanbrown, I'm still unable to get uploading images to work. Can I provide you with any more info on my environment or do you have any suggestions on how I can fix this?
Author
Owner

@ssddanbrown commented on GitHub (May 14, 2023):

@jacobolsen-vse I've just given this a test, and I think it's your location /uploads { block within your nginx config that's throwing things off. That's being matched so the request is never being passed to php.

Try removing that nginx config block.
autoindexing should be off by default, but if you did need that you could maybe define this via other means (Within the parent server block, or maybe in a nested location block within the location / { block).

@ssddanbrown commented on GitHub (May 14, 2023): @jacobolsen-vse I've just given this a test, and I think it's your `location /uploads {` block within your nginx config that's throwing things off. That's being matched so the request is never being passed to php. Try removing that nginx config block. autoindexing should be off by default, but if you did need that you could maybe define this via other means (Within the parent server block, or maybe in a nested location block within the `location / {` block).
Author
Owner

@jacobolsen-vse commented on GitHub (May 15, 2023):

@ssddanbrown Yes that was the problem! I've removed that block and uploading images now works! Thank you so much for your support! I'll go ahead and close this issue.

@jacobolsen-vse commented on GitHub (May 15, 2023): @ssddanbrown Yes that was the problem! I've removed that block and uploading images now works! Thank you so much for your support! I'll go ahead and close this issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3792