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
fix: add nginx support for webp images in hidden directory, sync nginx conf #5580
Conversation
Download the artifacts for this pull request:
See Testing a PR |
Please update the OP provide manual testing instructions. I assume you have already experimented with this using .ddev/nginx-full/nginx-site.conf? |
Right, I tested it with my changes in .ddev/nginx-full/nginx-site.conf and now the images can be displayed. |
Please test manually with the artifacts here, #5580 (comment) Don't forget to remove your .ddev/nginx-full/nginx-site.conf before testing. I note that TYPO3 config does this differently, https://github.com/ddev/ddev/blob/8b714e13632069299a9f3e3dbebc3c8442f8baf5/pkg/ddevapp/webserver_config_assets/nginx-site-typo3.conf I also note that only TYPO3 currently has explicit webp support. Would you consider sorting it out for the other project types? https://github.com/ddev/ddev/tree/master/pkg/ddevapp/webserver_config_assets |
I tested it with the ddev-macos-arm64.zip and it worked. |
They're all the same, thanks for testing. Would love to have you improve webp for the other project types as well :) |
Maybe I can spend some time on this in the next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this, it works fine.
However, I used upstream/master (v1.22.6) and it also worked fine without this patch.
Could you please re-check and make sure that this is actually needed? Is it possible you hit the wrong URL when testing or something?
I also checked drupal10 project type and it worked fine opening webp files with no modifications of any kind.
I rebased this and you can download and test artifacts at #5580 (comment)
I re-checked it with ddev 1.22.6 and can confirm it is needed. I used the same URL with a Magento 2 project. I did not check it with drupal. Before: Request URL: https://someproject.ddev.site/media/wysiwyg/someimage.webp After: Request URL: https://someproject.ddev.site/media/wysiwyg/someimage.webp |
Testing again with magento 2 2.4.6-p3, DDEV v1.22.6, macOS arm64. Test image attached here. Using Magento 2 quickstart from https://ddev.readthedocs.io/en/latest/users/quickstart/#magento, Chrome browser Following the testing instructions here, I copied testimage.webp to pub/media and then accessed Closing this, happy to reopen, happy to continue the conversation if you can give a more complete test scenario. I am unable to reproduce your situation. Is it possibly a different browser? |
@rfay i've got the same error on my local env. I've found the following error in the nginx error.log: Is it possible to reopen the issue? |
Hi @rfay please check the following urls. When I put the test.webp in a subdirectory with the name .renditions, it doesn't work anymore. Works: Doesn't work: |
Does it work if the directory is not a hidden directory? For example, if it's named |
yes, this work's also. |
So most likely the problem is not following into hidden directories? Can you try it with a jpg file? |
https://test.ddev.site/media/.renditions/suche.jpg work's also! |
So
? |
correct! |
And what happens with the changes proposed in this PR? |
I've modfied the nginx config file like the changes from pr. After restart nginx / ddev it work's perfectly |
I'm reopening, but please update the OP to say the specifics of what's going on here. @stasadev can you understand why this would happen? Are any changes required for apache-fpm? |
Added webp support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested the current logic, and when `.webp' is not added to the list, the path goes to the following condition:
location ~* /\.(?!well-known\/) {
deny all;
}
This PR also adds .webp
to /static/
and /media/
conditions, which is not needed. I placed the image to /pub/media/.test/1.webp
and /pub/static/test/1.webp
and it worked only with this condition:
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|webp)$
Are any changes required for
apache-fpm
?
It works fine with apache-fpm
.
We need to add .webp
to other nginx-site.conf
.
If you don't mind, I can do it.
I don't think anybody will object if you fix for the other CMS types @stasadev |
I added the missing conditions for The only files I haven't touched (don't know how to test them):
|
Thanks! We have some explicit examples in ddevapp_test.go as well I'm not sure it's super necessary to test those though. |
I tested it with test-django4-bakerydemo, and it didn't work. So I won't add anything else. |
great! Happy Wife, Happy Life 👍 @stephanie-ehrling |
I'm afraid this has had unexpected consequences, making Kirby completely fail when used with nginx. It appears that the change made here in https://github.com/ddev/ddev/pull/5580/files#diff-6633a7b4b2209acb43fe88d9cce12c93058ca2a2ff4f712e232bd1cda067c900R55-R63 is the cause of the problem. Looking back, I don't know how that snuck in here, or why it was related to webp images in hidden directory. I'm afraid this will need to be reverted, and we can try again. |
Added webp support for images in hidden directories.
The Issue
Webp images are not supported for magento 2 projects if the image is in a hidden directory. A request to a webp image will result in a HTTP 403 Error.
How This PR Solves The Issue
Changed nginx config to allow webp files as images in hidden directories.
Manual Testing Instructions
Add an image in webp format in a hidden directory i.e. https://test.ddev.site/media/.renditions/test.webp and request that image. Before the changes there is an error "403 Forbidden". After the changes the image is shown in the browser.
Automated Testing Overview
Related Issue Link(s)
Release/Deployment Notes