BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
15.32k stars 1.91k forks source link

Draw.io images broken #1702

Closed flamechair closed 5 years ago

flamechair commented 5 years ago

Describe the bug Draw.io images are not loading, HTTP 404

Steps To Reproduce Steps to reproduce the behavior:

  1. Go to any page
  2. Click on drawing
  3. Make any image, File -> Save
  4. See error

Expected behavior Images to show up both in edit mode and viewing mode

Screenshots If applicable, add screenshots to help explain your problem. https://imgur.com/a/FdY8s0C

Your Configuration (please complete the following information):

Additional context Config file:

APP_ENV=production
APP_DEBUG=false
APP_KEY=base64:<REDACTED>
APP_URL=https://<REDACTED>
APP_LANG=en
APP_AUTO_LANG_PUBLIC=true
DB_HOST=<REDACTED>
DB_PORT=<REDACTED>
DB_DATABASE=<REDACTED>
DB_USERNAME=<REDACTED>
DB_PASSWORD=<REDACTED>
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
SESSION_COOKIE_NAME=<REDACTED>
SESSION_SECURE_COOKIE=false
CACHE_PREFIX=bookstack
QUEUE_DRIVER=sync
STORAGE_TYPE=local_secure
AUTH_METHOD=standard
DISABLE_EXTERNAL_SERVICES=false
AVATAR_URL=https://seccdn.libravatar.org/avatar/${hash}?s=${size}&d=identicon
DRAWIO=true
APP_VIEWS_BOOKS=list
APP_VIEWS_BOOKSHELVES=grid
REVISION_LIMIT=50
ALLOW_CONTENT_SCRIPTS=false
ALLOW_ROBOTS=false
ssddanbrown commented 5 years ago

Hi @iamtpage, Sorry to hear drawings are not working.

Do the image files get created on the server-side? I'm just wondering if this is an issue during image creation/saving or an issue which locating and loading.

flamechair commented 5 years ago

Looks like the drawings do get created:

/var/www/html/storage/uploads/images/drawio # ls 2019-10/
Drawing-Tyler-1570569435.png

But the URL to access them 404's in the browser: HTTP 404: https://<REDACTED>/uploads/images/drawio/2019-10/Drawing-Tyler-1570569435.png

ssddanbrown commented 5 years ago

@iamtpage Thanks for checking.

Do other images work okay? Such as user images or normal images in page content?

flamechair commented 5 years ago

Other images have the same issue. They upload fine but the images fail to load in certain pages:

/var/www/html/storage/uploads/images/gallery # ls 2019-10/
Capture.PNG     scaled-1680-    thumbs-150-150
/var/www/html/storage/uploads/images/gallery # ls 2019-10/scaled-1680-/
Capture.PNG
/var/www/html/storage/uploads/images/gallery # ls 2019-10/thumbs-150-150/
Capture.PNG
/var/www/html/storage/uploads/images/gallery #

Could it be related to my nginx.conf?

/etc/nginx/conf.d # cat default.conf
server {
        listen 3500 default_server;

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

        server_name _;

        client_max_body_size 0;

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

        location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README) {
                deny all;
        }

        location ~ \.php(?:$|/) {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
                try_files $uri $uri/ =404;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;

        }

        location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
                expires 30d;
                access_log off;
        }
}
flamechair commented 5 years ago

Looks like initially the bug was with my nginx configuration, changing it to the following now lets regular pictures load without issue:

server {
    listen 80 default_server;

    root /var/www/html/public;
    index index.php index.html index.htm;
    server_name _;
    client_max_body_size 0;
    error_page 599 = @noauth;

    location @noauth {
        try_files $uri $uri/ /index.php?$args;
    }

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

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
    }
}

Now draw.io images return an HTTP 500 error when trying to load them, I'm enabling debug in the env file to see if I can dig around some more

flamechair commented 5 years ago

Updated stacktrace from loading draw.io images:

[2019-10-22 20:32:42] production.ERROR: Call to a member function bind() on null {"userId":0,"email":"acme@example.com","exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to a member function bind() on null at /var/www/html/vendor/laravel/framework/src/Illuminate/Support/HigherOrderTapProxy.php:34)
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(575): Illuminate\\Support\\HigherOrderTapProxy->__call('bind', Array)
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Illuminate\\Routing\\Router->respondWithRoute('fallback')
#2 /var/www/html/app/Exceptions/Handler.php(67): Illuminate\\Support\\Facades\\Facade::__callStatic('respondWithRout...', Array)
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(83): BookStack\\Exceptions\\Handler->render(Object(BookStack\\Http\\Request), Object(Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException))
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): Illuminate\\Routing\\Pipeline->handleException(Object(BookStack\\Http\\Request), Object(Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException))
#5 /var/www/html/app/Http/Controllers/Controller.php(44): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#6 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(131): BookStack\\Http\\Controllers\\Controller->BookStack\\Http\\Controllers\\{closure}(Object(BookStack\\Http\\Request), Object(Closure))
#7 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(BookStack\\Http\\Request))
#8 /var/www/html/app/Http/Middleware/Authenticate.php(48): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#9 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): BookStack\\Http\\Middleware\\Authenticate->handle(Object(BookStack\\Http\\Request), Object(Closure))
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(BookStack\\Http\\Request))
#11 /var/www/html/app/Http/Middleware/Localization.php(70): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): BookStack\\Http\\Middleware\\Localization->handle(Object(BookStack\\Http\\Request), Object(Closure))
#13 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(BookStack\\Http\\Request))
#14 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#15 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(BookStack\\Http\\Request), Object(Closure))
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(BookStack\\Http\\Request))
#17 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(68): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#18 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(BookStack\\Http\\Request), Object(Closure))
#19 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(BookStack\\Http\\Request))
#20 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#21 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(BookStack\\Http\\Request), Object(Closure))
#22 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(BookStack\\Http\\Request))
#23 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#24 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Session\\Middleware\\StartSession->handle(Object(BookStack\\Http\\Request), Object(Closure))
#25 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(BookStack\\Http\\Request))
#26 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#27 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(BookStack\\Http\\Request), Object(Closure))
#28 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(BookStack\\Http\\Request))
#29 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#30 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(BookStack\\Http\\Request), Object(Closure))
#31 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(BookStack\\Http\\Request))
#32 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#33 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(660): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#34 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(BookStack\\Http\\Request))
#35 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(601): Illuminate\\Routing\\Router->runRoute(Object(BookStack\\Http\\Request), Object(Illuminate\\Routing\\Route))
#36 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(590): Illuminate\\Routing\\Router->dispatchToRoute(Object(BookStack\\Http\\Request))
#37 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(BookStack\\Http\\Request))
#38 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(BookStack\\Http\\Request))
#39 /var/www/html/vendor/fideloper/proxy/src/TrustProxies.php(56): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#40 /var/www/html/app/Http/Middleware/TrustProxies.php(45): Fideloper\\Proxy\\TrustProxies->handle(Object(BookStack\\Http\\Request), Object(Closure))
#41 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): BookStack\\Http\\Middleware\\TrustProxies->handle(Object(BookStack\\Http\\Request), Object(Closure))
#42 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(BookStack\\Http\\Request))
#43 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#44 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(BookStack\\Http\\Request), Object(Closure))
#45 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(BookStack\\Http\\Request))
#46 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#47 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(BookStack\\Http\\Request), Object(Closure))
#48 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(BookStack\\Http\\Request))
#49 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#50 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(BookStack\\Http\\Request), Object(Closure))
#51 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(BookStack\\Http\\Request))
#52 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(BookStack\\Http\\Request))
#53 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#54 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(BookStack\\Http\\Request))
#55 /var/www/html/public/index.php(54): Illuminate\\Foundation\\Http\\Kernel->handle(Object(BookStack\\Http\\Request))
#56 {main}
"}
flamechair commented 5 years ago

Stacktrace caused by images that no longer existed. Will close and open a new issue to address draw.io images being blank.