mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
Merge pull request #3821 from mpalmer/letter-avatar-proxy
Proxy letter avatars by default
This commit is contained in:
commit
88f1a8f0b1
4 changed files with 24 additions and 4 deletions
|
@ -472,6 +472,7 @@ class User < ActiveRecord::Base
|
|||
url.gsub! "{color}", letter_avatar_color(username.downcase)
|
||||
url.gsub! "{username}", username
|
||||
url.gsub! "{first_letter}", username[0].downcase
|
||||
url.gsub! "{hostname}", Discourse.current_hostname
|
||||
url
|
||||
else
|
||||
"#{Discourse.base_uri}/letter_avatar/#{username.downcase}/{size}/#{LetterAvatar.version}.png"
|
||||
|
|
|
@ -180,7 +180,7 @@ server {
|
|||
# This big block is needed so we can selectively enable
|
||||
# acceleration for backups and avatars
|
||||
# see note about repetition above
|
||||
location ~ ^/(letter_avatar|user_avatar|highlight-js|stylesheets|favicon/proxied) {
|
||||
location ~ ^/(letter_avatar/|user_avatar|highlight-js|stylesheets|favicon/proxied) {
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
@ -199,6 +199,25 @@ server {
|
|||
break;
|
||||
}
|
||||
|
||||
location /letter_avatar_proxy/ {
|
||||
# Don't send any client headers to the avatars service
|
||||
proxy_method GET;
|
||||
proxy_pass_request_headers off;
|
||||
proxy_pass_request_body off;
|
||||
|
||||
# Don't let cookies interrupt caching, and don't pass them to the
|
||||
# client
|
||||
proxy_ignore_headers "Set-Cookie";
|
||||
proxy_hide_header "Set-Cookie";
|
||||
|
||||
proxy_cache one;
|
||||
proxy_cache_key $uri;
|
||||
proxy_cache_valid 200 7d;
|
||||
proxy_cache_valid 404 1m;
|
||||
|
||||
proxy_pass https://avatars.discourse.org/;
|
||||
}
|
||||
|
||||
# this means every file in public is tried first
|
||||
try_files $uri @discourse;
|
||||
}
|
||||
|
|
|
@ -595,9 +595,9 @@ files:
|
|||
client: true
|
||||
shadowed_by_global: true
|
||||
external_system_avatars_url:
|
||||
default: "https://avatars.discourse.org/v2/letter/{first_letter}/{color}/{size}.png"
|
||||
default: "/letter_avatar_proxy/v2/letter/{first_letter}/{color}/{size}.png"
|
||||
client: true
|
||||
regex: '^https?:\/\/.+[^\/]'
|
||||
regex: '^((https?:)?\/)?\/.+[^\/]'
|
||||
default_opengraph_image_url: ''
|
||||
|
||||
trust:
|
||||
|
|
|
@ -912,7 +912,7 @@ describe User do
|
|||
expect(user.small_avatar_url).to eq("//test.localhost/letter_avatar/sam/45/#{LetterAvatar.version}.png")
|
||||
|
||||
SiteSetting.external_system_avatars_enabled = true
|
||||
expect(user.small_avatar_url).to eq("https://avatars.discourse.org/v2/letter/s/5f9b8f/45.png")
|
||||
expect(user.small_avatar_url).to eq("//test.localhost/letter_avatar_proxy/v2/letter/s/5f9b8f/45.png")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue