-
-
Notifications
You must be signed in to change notification settings - Fork 882
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
Allow bypassing proxy for some domains with ProxyAllImages #4874
base: main
Are you sure you want to change the base?
Conversation
66556e0
to
31fc276
Compare
.pictrs_config()? | ||
.proxy_bypass_domains | ||
.iter() | ||
.any(|s| url.domain().expect("Invalid URL").starts_with(s)) |
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.
Panicing for non-domain hosts is unnecessary
.any(|s| url.domain().expect("Invalid URL").starts_with(s)) | |
.any(|s| url.domain().is_some_and(|domain| domain.starts_with(s))) |
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.
We've moved a lot of settings like this to the DB, so that they can be live updated in UIs. Then a lemmy restart wouldn't be required if you want to add one later.
But that can always be done later, and this is good for now.
.iter() | ||
.any(|s| url.domain().expect("Invalid URL").starts_with(s)) | ||
{ | ||
return Ok( |
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.
Can just do Ok(....)
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.
return
is required here because the if statement is not the last expression
I would consider bypassing some domains by default, such as imgur you mentioned. Because most admins wont know which ones can break. Though it should still be possible to remove the default values. If thats too complicated, its also good to list problematic domains somewhere in documentation. |
There should be a change to how requests for proxying are done:
|
This PR introduces a new settings parameter,
proxy_bypass_domains
, which allows admins to configure some domains for which image proxying will be skipped.The skipping logic is within the image_proxy/ endpoint itself, so URLs do not have to change whenever the bypass list is modified by admins. If any domain is on this bypass list, then instead of trying to proxy the image through pict-rs, Lemmy will just issue a HTTP redirect to the source image.
There are a couple of reasons such configuration can be useful. For example, imgur will very quickly start blocking all requests from Lemmy when running with ProxyAllImages, due do its rate limits. Additionally, a few Lemmy instances provide their own external image hosting service, this setting will allow them to not duplicate the same images in two places.