mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-20 06:58:00 +00:00
x-accell working
This commit is contained in:
@@ -7,6 +7,8 @@ WORKDIR /app/public
|
|||||||
|
|
||||||
RUN install-php-extensions redis exif gd
|
RUN install-php-extensions redis exif gd
|
||||||
|
|
||||||
|
ADD docker/rootfs/Caddyfile /etc/caddy/Caddyfile
|
||||||
|
|
||||||
# Add php.ini
|
# Add php.ini
|
||||||
ADD configs/php.ini /usr/local/etc/php/php.ini
|
ADD configs/php.ini /usr/local/etc/php/php.ini
|
||||||
|
|
||||||
|
|||||||
28
docker/rootfs/Caddyfile
Normal file
28
docker/rootfs/Caddyfile
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
frankenphp
|
||||||
|
}
|
||||||
|
|
||||||
|
localhost:80 {
|
||||||
|
log
|
||||||
|
|
||||||
|
encode zstd br gzip
|
||||||
|
|
||||||
|
root web/
|
||||||
|
|
||||||
|
#request_header X-Sendfile-Type x-accel-redirect
|
||||||
|
#request_header X-Accel-Mapping ../data=/data
|
||||||
|
intercept {
|
||||||
|
@sendfile header X-Accel-Redirect *
|
||||||
|
handle_response @sendfile {
|
||||||
|
root data/
|
||||||
|
rewrite * {resp.header.X-Accel-Redirect}
|
||||||
|
method * GET
|
||||||
|
header -X-Accel-Redirect
|
||||||
|
file_server
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
php_server {
|
||||||
|
try_files {path} index.php
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -96,4 +96,4 @@ echo ' [+] Creating config'
|
|||||||
|
|
||||||
_buildConfig > src/inc/config.inc.php
|
_buildConfig > src/inc/config.inc.php
|
||||||
|
|
||||||
frankenphp php-server --listen ":80" --root /app/public/web
|
frankenphp run --config /etc/caddy/Caddyfile
|
||||||
@@ -199,7 +199,7 @@ class ImageController implements ContentController
|
|||||||
}
|
}
|
||||||
|
|
||||||
header ("Content-type: image/jpeg");
|
header ("Content-type: image/jpeg");
|
||||||
readfile($preview);
|
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$preview));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else if(in_array('download',$url))
|
else if(in_array('download',$url))
|
||||||
@@ -212,7 +212,7 @@ class ImageController implements ContentController
|
|||||||
header('Cache-Control: must-revalidate');
|
header('Cache-Control: must-revalidate');
|
||||||
header('Pragma: public');
|
header('Pragma: public');
|
||||||
header('Content-Length: ' . filesize($path));
|
header('Content-Length: ' . filesize($path));
|
||||||
readfile($path);
|
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$path));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,7 +244,7 @@ class ImageController implements ContentController
|
|||||||
header ("Last-Modified: ".gmdate('D, d M Y H:i:s ', filemtime($path)) . 'GMT');
|
header ("Last-Modified: ".gmdate('D, d M Y H:i:s ', filemtime($path)) . 'GMT');
|
||||||
header ("ETag: $hash");
|
header ("ETag: $hash");
|
||||||
header('Cache-control: public, max-age=31536000');
|
header('Cache-control: public, max-age=31536000');
|
||||||
readfile($path);
|
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$path));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'png':
|
case 'png':
|
||||||
@@ -252,7 +252,8 @@ class ImageController implements ContentController
|
|||||||
header ("Last-Modified: ".gmdate('D, d M Y H:i:s ', filemtime($path)) . 'GMT');
|
header ("Last-Modified: ".gmdate('D, d M Y H:i:s ', filemtime($path)) . 'GMT');
|
||||||
header ("ETag: $hash");
|
header ("ETag: $hash");
|
||||||
header('Cache-control: public, max-age=31536000');
|
header('Cache-control: public, max-age=31536000');
|
||||||
readfile($path);
|
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$path));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'gif':
|
case 'gif':
|
||||||
@@ -260,7 +261,7 @@ class ImageController implements ContentController
|
|||||||
header ("Last-Modified: ".gmdate('D, d M Y H:i:s ', filemtime($path)) . 'GMT');
|
header ("Last-Modified: ".gmdate('D, d M Y H:i:s ', filemtime($path)) . 'GMT');
|
||||||
header ("ETag: $hash");
|
header ("ETag: $hash");
|
||||||
header('Cache-control: public, max-age=31536000');
|
header('Cache-control: public, max-age=31536000');
|
||||||
readfile($path);
|
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$path));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'webp':
|
case 'webp':
|
||||||
@@ -268,7 +269,7 @@ class ImageController implements ContentController
|
|||||||
header ("Last-Modified: ".gmdate('D, d M Y H:i:s ', filemtime($path)) . 'GMT');
|
header ("Last-Modified: ".gmdate('D, d M Y H:i:s ', filemtime($path)) . 'GMT');
|
||||||
header ("ETag: $hash");
|
header ("ETag: $hash");
|
||||||
header('Cache-control: public, max-age=31536000');
|
header('Cache-control: public, max-age=31536000');
|
||||||
readfile($path);
|
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$path));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class TextController implements ContentController
|
|||||||
header('Cache-Control: must-revalidate');
|
header('Cache-Control: must-revalidate');
|
||||||
header('Pragma: public');
|
header('Pragma: public');
|
||||||
header('Content-Length: ' . filesize($path));
|
header('Content-Length: ' . filesize($path));
|
||||||
readfile($path);
|
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$path));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ class VideoController implements ContentController
|
|||||||
}
|
}
|
||||||
|
|
||||||
header ("Content-type: image/jpeg");
|
header ("Content-type: image/jpeg");
|
||||||
readfile($preview);
|
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$preview));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(in_array('download',$url))
|
else if(in_array('download',$url))
|
||||||
{
|
{
|
||||||
@@ -57,7 +57,7 @@ class VideoController implements ContentController
|
|||||||
header('Cache-Control: must-revalidate');
|
header('Cache-Control: must-revalidate');
|
||||||
header('Pragma: public');
|
header('Pragma: public');
|
||||||
header('Content-Length: ' . filesize($path));
|
header('Content-Length: ' . filesize($path));
|
||||||
readfile($path);
|
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$path));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user