x-accell working

This commit is contained in:
Chris
2025-07-09 17:44:36 +02:00
parent 9cd543d351
commit 1dfdb4b0b2
6 changed files with 42 additions and 11 deletions

View File

@@ -7,6 +7,8 @@ WORKDIR /app/public
RUN install-php-extensions redis exif gd
ADD docker/rootfs/Caddyfile /etc/caddy/Caddyfile
# Add php.ini
ADD configs/php.ini /usr/local/etc/php/php.ini

28
docker/rootfs/Caddyfile Normal file
View 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
}
}

View File

@@ -96,4 +96,4 @@ echo ' [+] Creating config'
_buildConfig > src/inc/config.inc.php
frankenphp php-server --listen ":80" --root /app/public/web
frankenphp run --config /etc/caddy/Caddyfile

View File

@@ -199,7 +199,7 @@ class ImageController implements ContentController
}
header ("Content-type: image/jpeg");
readfile($preview);
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$preview));
exit;
}
else if(in_array('download',$url))
@@ -212,7 +212,7 @@ class ImageController implements ContentController
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($path));
readfile($path);
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$path));
exit;
}
}
@@ -244,7 +244,7 @@ class ImageController implements ContentController
header ("Last-Modified: ".gmdate('D, d M Y H:i:s ', filemtime($path)) . 'GMT');
header ("ETag: $hash");
header('Cache-control: public, max-age=31536000');
readfile($path);
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$path));
break;
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 ("ETag: $hash");
header('Cache-control: public, max-age=31536000');
readfile($path);
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$path));
break;
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 ("ETag: $hash");
header('Cache-control: public, max-age=31536000');
readfile($path);
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$path));
break;
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 ("ETag: $hash");
header('Cache-control: public, max-age=31536000');
readfile($path);
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$path));
break;
}
}

View File

@@ -32,7 +32,7 @@ class TextController implements ContentController
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($path));
readfile($path);
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$path));
exit;
}
}

View File

@@ -44,7 +44,7 @@ class VideoController implements ContentController
}
header ("Content-type: image/jpeg");
readfile($preview);
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$preview));
}
else if(in_array('download',$url))
@@ -57,7 +57,7 @@ class VideoController implements ContentController
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($path));
readfile($path);
header('X-Accel-Redirect: '.str_replace(getDataDir().DS,'',$path));
exit;
}
}