Thread: Image Proxy
View Single Post
  #1  
Old 10th February 2018, 15:12
darkalchemy darkalchemy is offline
Administrator
 
Join Date: Dec 2017
United States
Posts: 101
Default Image Proxy
Simple-Image-ProxyClick the image to open in full size.
The purpose of this image proxy is to reduce the exposure of the requesting sites url, when hot-linking images, by using the image proxy to make the http request, store the image and return the image from the image proxy in an http response.

This could also be used to serve images that are using http links on your https site. Thereby not opening up a security hole.

This image proxy will store an optimized for web version of the original image and can return that image in any dimensions that are included with the http request.

How To:
get the code
Code:
git clone https://github.com/darkalchemy/Simple-Image-Proxy.git image-proxy
set ownership
Code:
chown -R www-data:www-data image-proxy
install dependancies
Code:
cd image-proxy
composer install
set webroot to path image-proxy/public
edit settings.php
Code:
replace the uid and key with values given to the requsting site. These values must match.
Usage by the requsting site
add class with composer
Code:
composer require blocktrail/cryptojs-aes-php
use class in site
Code:
use Blocktrail\CryptoJSAES\CryptoJSAES;
to return image without modification
Code:
$encrypted = CryptoJSAES::encrypt($url, $key);
return 'http://image_proxy_url/image?' . base64_encode($encrypted . '&uid=' . uid);
to return image and resize the image
Code:
$encrypted = CryptoJSAES::encrypt("$url&width={$width}&height={$height}", $key);
return 'http://image_proxy_url/image?' . base64_encode($encrypted . '&uid=' . uid);
This image proxy is in use with Pu-239, if you care to see it, but can be used with any site that makes a proper request.

How to add to your site.

The code is licensed MIT and is available on github.
https://github.com/darkalchemy/Simple-Image-Proxy

Last edited by darkalchemy; 11th February 2018 at 10:56.
Reply With Quote
The Following User Says Thank You to darkalchemy For This Useful Post:
romano1 (10th February 2018)