Skip to content

Images not displaying #224

Open
weja opened this Issue · 44 comments

8 participants

@weja

For some reason images stopped working for me few weeks ago.
They just do not display and show "broken image link" in browser.
It worked before, but there is also chance that I broke something..

You can see & try problem here:
https://8pallo.fi/test/thread/1

And btw, I had problem with posting before on nginx, that was fixed with this line:
/index.php$is_args$args (arguments had to be added like this, apache did it by default).

I know you're busy with migration, just wanted to add this here while I got nothing better to do :P

@jaw-sh
@weja

What is not valid URL ?
https://8pallo.fi doesn't work for you or is my configuration bad?

@QuakersOat

I had this issue for a period of time, and it was solved by tweaking with my nginx block. My guess is that you've set your /path/to/next/storage/app/attachments wrong, and that is why images aren't displaying. Try tweaking with your configuration until you get it.

@b3y0ndd34th

I am also experiencing this issue.

I believe I have the .env correct
APP_URL_MEDIA= (domain.tld)/infinityfolder/storage/app/attachments/

When I inspect the element the img src is set to
"http://(domain.tld)/infinityfolder/storage/app/attachments/file/thumb/2/1452368290-0.jpg?board=test"

Is this the correct behavior? or have I not configured the .env correctly?

@jaw-sh
@b3y0ndd34th

Leaving MEDIA in the .env blank does change the src.

Now I am looking at src="http://(domain.tld)/infinityfolder/public/index.php/b/file/thumb/2/1452368290-0.jpg"

but I still don't see any images.

@jaw-sh
@b3y0ndd34th

No that's the way my .env file is set up. After removing the info from the APP_URL_MEDIA I am able to see the images, but ONLY if I type in the index.php at the end of the URL.

If the index.php is missing from the URL, none of the board links or images work.

I will set up a fresh test later this afternoon to gather a better understanding on the issue (which is probably entirely on my end and something funky I did :) but I wanted to give anyone else experiencing the issue some more information on my particular problem.)

@jaw-sh

@b3y0ndd34th Are you still having this issue with my latest commit?

@TonySpahgetti

Using the latest commit, having this issue as well, though, I feel it might be related to the .env config, since the uploads are in both storage/app/attachments and in the file_attachments table.

APP_URL=http://xx.xx.xx.xx
APP_URL_MEDIA=
is what I got

Also verified that Apache was working and configured properly, and confirmed that my VirtualHost config was 'salright.

@milezzz

Guys it works 100% and always has with these settings:

APP_URL=//larachan.foo
APP_URL_MEDIA=

Just confirmed with my copy.

@TonySpahgetti

No dice @milezteg

It's most likely a backend configuration though, I'll keep digging in on my end.

@b3y0ndd34th

I will give the latest commit a go when I get home this evening, thanks for your work on this.

@b3y0ndd34th

Had to edit this because I forgot to refresh and had a previous issue still plaguing. I deleted that comment and wrote this one. As far as I can tell, everything is set up correctly (I use your recommended settings for apache). And this is running on an Ubuntu 15.04 server.

Sorry but I still seem to be getting this issue.

I clone github to /srv/www/website/

I set apache to server /srv/www/website/public as the root directory.

I run the composer update after adjusting only the APP_URL=//mychanname.tld and setting the information for my sql database in the .env file.

Then when I browse to the site, the styling works, but images don't show.

I have to add "index.php" to the end of my URL in order for images to show.

I hope this helps to explain the issue. I am running an Ubuntu 15.04 server with Apache 2. I have used the recommended settings for apache 000-default.conf file. (except for when testing to see why the files, styling, or images are not showing)

Please let me know if there is something else I can do to narrow down the issue for you.

If I click on the board links, I get a 404 error with a url of http://(url.tld)/test

If I add /index.php at the end of my url, then I click the boards, I can browse the boards, but no images display.

This is the error chrome displays.
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
http://mychanname.tld/index.php/test/file/thumb/1/1452474291-0.jpg

@TonySpahgetti

@b3y0ndd34th

Strange, Was getting 500 errors too when I would refresh the "blank" image (opening the link to the image in a separate browser tab)
I'll nuke my server and try another fresh installation, was using CentOS 7.0 with PHP 5.6 and Apache 2

ErrorException in ImageController.php line 302:
filesize(): stat failed for /var/www/html/infinity-next/storage/app/attachments/full/5/c/6/6/5c66e7354410f2bcfb77ab8a5d3d97b7
in ImageController.php line 302
at HandleExceptions->handleError('2', 'filesize(): stat failed for /var/www/html/infinity-next/storage/app/attachments/full/5/c/6/6/5c66e7354410f2bcfb77ab8a5d3d97b7', '/var/www/html/infinity-next/app/Http/Controllers/Content/ImageController.php', '302', array('hash' => '5c66e7354410f2bcfb77ab8a5d3d97b7', 'filename' => '1452697203-0.jpg', 'thumbnail' => false, 'FileStorage' => object(FileStorage), 'storagePath' => 'attachments/full/5/c/6/6/5c66e7354410f2bcfb77ab8a5d3d97b7', 'storagePathFull' => '/var/www/html/infinity-next/storage/app/attachments/full/5/c/6/6/5c66e7354410f2bcfb77ab8a5d3d97b7', 'cacheTime' => '31536000', 'storageExists' => false))

Turns out the "Full" folder didn't exist, created it, and applied the appropriate permissions, only to get the same error.

@b3y0ndd34th

I only get the 500 errors on the images themselves, not the pages.

@milezzz

Latest changes break the Laravel debugger. Try turning it off in your .env:

APP_DEBUG=false

@b3y0ndd34th

Thanks for the info milezteg!

Unfortunately, the issues are still present with the debugger disabled :(

milezteg, if you don't mind my asking, what environment are you installing this to? I can spin up another server with a different OS if that may be a possible issue.

@milezzz

Deb 8 + Php-fpm 5.6 + mysql

Make sure to do php artisan clear:cache

Surprised that didn't fix it I had a similar issue. Also be sure to chmod -R 755 storage/app/attachments for some reason it was set to -r for those.

@jaw-sh

You should not have to 755 the attachments directory. Make sure you've given ownership permissions to your application that match your PHP daemon. 500 errors on images mean the image that should exist does not.

@TonySpahgetti

I have storage/app/attachments owned by apache:apache. Still getting blank images, though the 500 errors upon refreshing, along with a spew of text has stopped.

Fresh installation, Centos 7.0 + Php-fpm 5.6 + MariaDB

will keep tinkering.

@Netifriik

Having the same issue. Blank images on Ubuntu 14.04 and Apache. All the files are owned by www-data group and chmod 755 on the storage folder.

At first I somehow managed to see full images but thumbnails did not show. Now I can't see any images at all.

@milezzz

Hmm I had this same issue but fixed it by making sure permissions were correct as well as disabling the laravel debugger. Honestly though guys Josh is working on a caching layer so I wouldn't expect a lot of things to work 100% for at least a couple weeks.

@Netifriik

Got the images to work using nginx. I have no idea..
Most likely had to do with the resources path, in nginx config it's defined but with apache?

@jaw-sh
@Netifriik

I did add X-SendFile to Apache config. Also downloaded the module.
But it's very possible I misconfigured something. Now I have an issue with captchas, images work but captcha's don't show up.

@Graham--M

I thought it was supposed to work without xsendfile too? I couldn't get the php only output to work. So I installed the module, enabled it in the apache config, and enabled it in the vhost config with the correct directory set.

Then the server stopped sending the xsendfile header but I was still getting 0kb and a filetype header so something else was wrong.

I traced the pipeline execution to Barryvdh\HttpCache\Middleware\CacheRequests as the request wasn't touching the ImageController.php or the router.

Turns out @milezteg was slightly off. The command to clear the cache is:
php artisan httpcache:clear
and that got it to serve attachments properly. Whew.

@Netifriik

Any idea why my captcha is not working? Also a bit offtopic but are .webm filetypes supported? I seem to be getting integrity check errors.

@Graham--M

@Netifriik, I had a look. Captchas aren't working for me either. Similar problem as before; the cacherequests middleware seems to swallow the captcha image. I'm not sure if I should be seeing those cache headers for a captcha image?

Age: 0
Cache-Control: max-age=86400, pre-check=86400, public
Connection: Keep-Alive
Content-Disposition: inline
Content-Length: 0
Content-Type: image/png
Date: Fri, 15 Jan 2016 19:54:43 GMT
Expires: Sat, 16 Jan 2016 19:54:44 +0000
Keep-Alive: timeout=5, max=100
Last-Modified: Fri, 15 Jan 2016 19:36:56 +0000
Server: Apache/2.4.7 (Ubuntu)
Set-Cookie: laravel_session=[snipped for readability]
X-Powered-By: PHP/5.5.9-1ubuntu4.14
X-Symfony-Cache: GET /cp/captcha/default/611b11609e95afde9af0213a8d8640b4f6d0a895.png: miss, store
filename: 611b11609e95afde9af0213a8d8640b4f6d0a895.png
x-content-digest: [snipped for readability]
@Netifriik

It has something to do with the Response::stream method. If I replace the Streaming Response in getAsResponse($profile = "default") function with a simple Response::make function it works.

@Graham--M

@Netifriik Yeah. The symfony/StreamedResponse returns false for getContent() because it's meant to be streamed but that is what the symfony/HttpCache uses to cache the request and it overwrites the Content-Length size with strlen($response->getContent()) which cast to a number gives a length of zero.

If you comment this line out then it serves the image correctly (but the server cache is still wrong; also I set 'allow_reload' => true in the httpcache config so I could see the uncached behavior).

@TonySpahgetti

Still getting the issue on Apache, permissions are correct, Xsendfile is configured and loaded, debugger disabled, cleared the httpcache.

No dice on my end, I'll try switching over to NGINX

@jaw-sh
@b3y0ndd34th

Thanks for the info Josh, I was going to make a post this afternoon after work.

I did some HEAVY testing this weekend using Ubuntu and Debain. I was not able to use Apache and xsendfile.

I will try to set up mod_php. (not familiar with nginx is all). If I am unable to get that to work, I will try to learn nginx.

Do you recommend any changes to the Apache config? (other than removing the xsendfile portions)

**EDIT* php_mod is already enabled on my Ubuntu Apache server, What other recommendations do you have?

Loaded Modules: core mod_so mod_watchdog http_core mod_log_config mod_logio mod_version mod_unixd mod_access_compat mod_actions mod_alias mod_auth_basic mod_auth_digest mod_authn_core mod_authn_file mod_authz_core mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dav mod_dav_fs mod_deflate mod_dir mod_env mod_fastcgi mod_fcgid mod_filter mod_include mod_mime prefork mod_negotiation mod_php5 mod_python mod_rewrite mod_setenvif mod_socache_shmcb mod_ssl mod_status mod_suexec mod_suphp mod_xsendfile

@b3y0ndd34th

I am setting up nginx on a test server at the moment.

Like I said, I have no experience with nginx, so I am bound to have errors.

I have run out of time for the evening. I got everything installed and I will do some troubleshooting tomorrow. Right now I get a blank page when it tries to load the index.php.

I will provide more info when I can.

Thanks again for your work on this.

@Graham--M

@b3y0ndd34th Are you done with Apache and mod_php then? Remember that x-sendfile has to be enabled for the virtual host itself (here's a quick example):

/etc/apache2/sites-available/next.conf

<VirtualHost *:80>
    DocumentRoot "/var/www/next/public"

    <Directory "/var/www/next/public">
        AllowOverride all
    </Directory>

    <IfModule mod_xsendfile.c>
        XSendFile on
        XSendFilePath "/var/www/next/"
    </IfModule>
</VirtualHost>
@b3y0ndd34th

@Graham--M Thanks for the reply.

I would REALLY like to use Apache, as I have a web server with a number of projects already set up and working properly through Apache. This would be a nice addition.

If I have to use nginx, I will have to build a new server and learn to port everything to that server ( I want to have an Apache fallback just in case, it is what I am comfortable with).

Here is the CURRENT output of my Apache conf for the domain. I have tried various set ups in the Apache config to try to figure out where the issue was and this was the last one I tried.

Edit fixed the code display.

<VirtualHost *:80>
    ServerName domain.tk
    ServerAlias *.domain.tk

    DocumentRoot /srv/www/website/public
<Directory "/srv/www/website/public">
        AllowOverride all
</Directory>

    DirectoryIndex index.php

<IfModule mod_xsendfile.c>
        XSendFile on
        XSendFilePath "/srv/www/website/"
    </IfModule>
</VirtualHost>

I've had XSendFile enabled since beginning this project.

But none of the images that are submitted to the board show :(
Only the logos from the srv/www/domain/public/static folder will show.

The reason I was attempting to set up nginx, is because some have reported success, and I wanted to eliminate the Apache variable as my issue.

I can provide my nginx information and error logs later (I powered the server off last night when I was done for the night)

@Graham--M

@b3y0ndd34th That config looks similar to what I've got and it looks like you've got xsendfile installed properly since I assume what you pasted was the loaded modules dump output and it's in there.

First time I started the server and I didn't have xsendfile configured properly, it wound up caching the broken responses and it didn't work, even after I configured it properly. After I did php artisan httpcache:clear to clear the cache and that fixed it.

If clearing the cache isn't working then you could have a look to see what headers the server is sending you. In chrome if you open an attachment in a tab, right click and choose inspect, switch to the network tab in the developer tools, and hit CTRL + F5 and click on the request, you should see the response headers.

I'm guessing you'll have a status of 200 and a Content-Length of 0 but if you see the X-Sendfile header then the module isn't handling the response.

@b3y0ndd34th

Edit
Not sure what finally did it, but I have ran that http clear cache command a few times.

I ran a git fetch just a few minutes ago, and now I see my images...

I'll take it.

Thanks for your work on this Graham--M

@Graham--M

@b3y0ndd34th From the headers you had in your original post, it definitely wasn't a cache problem and I can't see what would have fixed it in the commits, but I'm glad it's working for you now.

@jaw-sh I see you fixed the captcha to use Response::make. Are you aware that you are still using Response::stream here for images?

@TonySpahgetti

I've configured it in NGINX and am having the same issues with the images, though, I feel as if it's my NGINX configuration (as it's a *107 rewrite or internal redirection cycle while internally redirecting to, error)

which is a start, I'll post an update once I'm good on my end, and note all the steps
Thank ye @Graham--M and @jaw-sh @milezteg for all the assistance.

@weja

I don't have a slightest clue what could be the problem..
I have both nginx and apache running on same web root, but on different ports.
Both have same problem, images do not display very similar way.. I've done my all, configured nginx and apache all possible ways, no idea what could be causing this.. It worked before on both web servers by just setting the webroot folder..

http://8pallo.fi <- nginx
http://8pallo.fi:81 <- apache, xsendfile manually enabled

@jaw-sh
@weja

I found installation instructions for Next, now it works on nginx..
This was required part (was not required before, sure it worked before, heh):

location /attachments {
    internal;
    # Yes, this must be an absolute path.
    # You're in for a bad time if it isn't.
    alias /my/path/to/next/storage/app/attachments;
}

Now it all works on nginx. But not on apache though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.