initial commit
This commit is contained in:
parent
15018c40cb
commit
1d835d9c0f
26
README.md
26
README.md
|
@ -1,3 +1,27 @@
|
|||
# pixelfed-imgproxy-apache2
|
||||
|
||||
Media proxy project for pixelfed. This project makes images, videos from remote pixelfed instances URLs proxied through the homeserver.
|
||||
Media proxy project for pixelfed. This project makes images,
|
||||
videos from remote pixelfed instances URLs proxied through the homeserver.
|
||||
|
||||
|
||||
## Installation (standalone)
|
||||
|
||||
Copy the code to your pixelfed installation
|
||||
```bash
|
||||
cp -a imgproxy /var/www/public/imgproxy
|
||||
```
|
||||
|
||||
Add the following lines in your apache Virtualhost configuration
|
||||
(replace pixel.nogafam.es to your instance URL)
|
||||
```apache2
|
||||
AddOutputFilterByType SUBSTITUTE application/json
|
||||
Substitute "s@(?<=\")https:\\\/\\\/[^\"]+\.(png|jpg|jpeg)@https:\\\/\\\/pixel.nogafam.es\\\/imgproxy\\\/?url=$0@i"
|
||||
Substitute "s@(?<=\")https://[^\"]+\.(png|jpg|jpeg)@https://pixel.nogafam.es/imgproxy/?url=$0@i"
|
||||
```
|
||||
|
||||
Enable `mod_substitute` on Apache
|
||||
```bash
|
||||
a2enmod substitute
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
$url = trim($_GET['url']);
|
||||
|
||||
# check url matches a https://domain/storage/whatever.jpeg url for images
|
||||
if (preg_match('/^https:\/\/[^\/]+\/storage\/[^\s\%]+\.(png|jpg|jpeg)(\?v=[^\&])?$/', $url)) {
|
||||
if (preg_match('/^.*\.png(\?v=[^\&])?$/', $url))
|
||||
header('Content-Type: image/png');
|
||||
else if (preg_match('/^.*\.(jpg|jpeg)(\?v=[^\&])?$/', $url))
|
||||
header('Content-Type: image/jpeg');
|
||||
echo file_get_contents($url);
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue