Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache images are not found #1061

Closed
Romain opened this issue Feb 20, 2018 · 6 comments
Closed

Cache images are not found #1061

Romain opened this issue Feb 20, 2018 · 6 comments

Comments

@Romain
Copy link

Romain commented Feb 20, 2018

Q A
Bug Report? no
Feature Request? no
BC Break Report? no
RFC? no
Imagine Bundle Version 1.9.1

Hi, I've been struggling for quite some time on this issue, and I've been investigating a lot without any luck.

I've a working install of Symfony 2.8.x and LiipImagineBundle v1.9.1. I recently changed my hosting provider for many reasons, and on the new one, cache images are not resolved. The setup of the server is exactly the same: Ubuntu 16.04 with PHP7.0, Nginx. php7.0-gd is installed.
Some people recommended to have php7.0-exif installed, I installed it. Same with phpinfo.

The cache images are properly resolved and generated (I can see them on the server), but when I try to load them, I get a 404:

[2018-02-20 12:18:32] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /media/cache/profile_pic/uploads/avatars/f479d1ac20-1519125336.jpg"" at /www/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php line 179 {"exception":"[object] (Symfony\Component\HttpKernel\Exception\NotFoundHttpException(code: 0): No route found for "GET /media/cache/profile_pic/uploads/avatars/f479d1ac20-1519125336.jpg" at /www/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php:179, Symfony\Component\Routing\Exception\ResourceNotFoundException(code: 0): at /www/app/cache/prod/appProdProjectContainerUrlMatcher.php:591)"} []

The files are now hosted on a NFS, but we had the same problem before moving them on this NFS.

Here is the config.yml:

# Liip Image Manager Configuration
liip_imagine:
    resolvers:
        default:
            web_path:
                web_root: "%kernel.root_dir%/../web"
                cache_prefix: "media/cache"

    loaders:
        default:
            filesystem:
                data_root:
                    - "%kernel.root_dir%/../"
                    - "%kernel.root_dir%/../web/"
                    - "%kernel.root_dir%/../web/uploads"
                    - "%kernel.root_dir%/../web/uploads/avatars"

    filter_sets:
        cache: ~
        profile_pic_menu:
            quality: 75
            filters:
                thumbnail: { size: [40, 40], mode: outbound }
        profile_pic:
            quality: 75
            filters:
                thumbnail: { size: [80, 80], mode: outbound }

Here is the routing.yml:

_liip_imagine:
    resource: "@LiipImagineBundle/Resources/config/routing.xml"

If you have any clue, it would really help.
Thanks a lot.

@cedricziel
Copy link
Collaborator

So.. I think if you really have resolved images at %kernel.root_dir%/../web/media/cache which essentially translates to webroot/media/cache, then you might have some issues with either a permissions on a mount point (if you mount that directory as well) or you're missing an important part of your nginx configuration. I'd say you should short-circuit requests for existing files.

@Romain
Copy link
Author

Romain commented Feb 21, 2018

Thanks for your answer @cedricziel !
I'll check with @ymazzer for the question of rights on the mount point. I'm not sure if it can help but here are the rights of the cache folder subdirectories:

capture d ecran 2018-02-21 a 09 19 36

I also checked the Nginx config and cannot see anything that could be the problem.
I have the rewriting set up as adviced:

location / {
    index app.php;
    try_files $uri @rewriteapp;
}

location @rewriteapp {
    rewrite ^(.*)$ /app.php/$1 last;
}

@applizem
Copy link

applizem commented Jun 17, 2019

Hi romain !! Did you find solution for your problem ? I have exactly the same problem. I realize the problem may not be LiipImagineBundle but the NFS volume mounted.

@Romain
Copy link
Author

Romain commented Jun 18, 2019

@applizem Unfortunately not, we never managed to sort this out, and we eventually shut down the service for other reasons, this was not critical.

@applizem
Copy link

Ah ok I understand. thanks you for your answer. I finally managed to fix my problem with kubernetes. I do not know if it was the same as yours. But the concern was that the volume was mounted on the php container. And I don't know for what reason the container nginx only saw the files physically in the php container and not volumes mounted in it. So I mounted the volume on the nginx container too. And everything seems to work now.

@michellesanver
Copy link
Contributor

Seems like this issue was fixed and not relevant anymore where it was not, I am closing this issue for now :) Of course let me know if there's any problems and we can re-open/open a new issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants