Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: tjbalon on December 13, 2017, 09:12:13 PM

Title: Proxy Handler for Images..
Post by: tjbalon on December 13, 2017, 09:12:13 PM
So I'm not too sure where to put this, this is a bit of a support request I suppose.

Why is it that the image proxy only proxies images which are non-ssl? To what I've seen on most websites, every image will go through the proxy, non-cached, take github camo for example.

Is there an easy way to extend the proxy to proxy EVERY image instead of just those that are non-SSL.

Thanks,
TJ
Title: Re: Proxy Handler for Images..
Post by: Arantor on December 14, 2017, 03:10:26 AM
Because there's no point in using your bandwidth for images that will show up.

GitHub etc have a fairly large stack of servers just for handling images so it goes faster. Unless you plan on building your own CDN, changing the proxy as you suggest will make your entire site slower.
Title: Re: Proxy Handler for Images..
Post by: tjbalon on December 15, 2017, 07:52:28 PM
Quote from: Arantor on December 14, 2017, 03:10:26 AM
Because there's no point in using your bandwidth for images that will show up.

GitHub etc have a fairly large stack of servers just for handling images so it goes faster. Unless you plan on building your own CDN, changing the proxy as you suggest will make your entire site slower.

Yeah I understand that for the most part, however we don't cache the images we simply just proxy them in-view. Is there an easy change to make it go for all images as of right now, or is that functionality difficult to achieve? I have not really gone through the proxy code, wouldn't imagine a temp change would be difficult. Considered writing a mod for it in the future, but I don't think it'd pass with that closing statement of the site being slower.
Title: Re: Proxy Handler for Images..
Post by: vbgamer45 on December 15, 2017, 10:40:24 PM
There are five spots that you need to change to ache all just have to remove http/s checks in the code such as
Require code changes such as          

if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false)
$user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret);



if (substr($data, 0, 8) != 'https://' && $image_proxy_enabled)
$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);

Title: Re: Proxy Handler for Images..
Post by: tjbalon on December 16, 2017, 12:13:43 AM
Quote from: vbgamer45 on December 15, 2017, 10:40:24 PM
There are five spots that you need to change to ache all just have to remove http/s checks in the code such as
Require code changes such as          

if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false)
$user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret);



if (substr($data, 0, 8) != 'https://' && $image_proxy_enabled)
$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);


Thanks vbgamer, you rock dude :^)
Title: Re: Proxy Handler for Images..
Post by: vbgamer45 on December 16, 2017, 12:35:50 AM
Glad to help