Skip to content

Commit f9d9f48

Browse files
authored
feat: X-Sendfile example (dunglas#28)
1 parent fd32c07 commit f9d9f48

9 files changed

Lines changed: 785 additions & 718 deletions

File tree

Caddyfile

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
{
2-
# This file is only used for dev and benchmarking.
3-
# Please see /etc/Caddyfile in the container, for the one that is actual used in this demo
4-
5-
#debug
62
frankenphp {
73
worker ./public/index.php
84
}
95
}
106

117
localhost {
12-
#log
13-
route {
14-
root * public/
15-
#php_fastcgi 127.0.0.1:9000
16-
php_server
8+
log
9+
10+
encode zstd br gzip
11+
12+
root public/
13+
14+
request_header X-Sendfile-Type x-accel-redirect
15+
request_header X-Accel-Mapping ../private-files=/private-files
16+
intercept {
17+
@sendfile header X-Accel-Redirect *
18+
handle_response @sendfile {
19+
root private-files/
20+
rewrite * {resp.header.X-Accel-Redirect}
21+
method * GET
22+
header -X-Accel-Redirect
23+
file_server
24+
}
25+
}
26+
27+
php_server {
28+
try_files {path} index.php
1729
}
1830
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Run the project with Docker (worker mode):
2626
```console
2727
docker run \
2828
-e FRANKENPHP_CONFIG="worker ./public/index.php" \
29+
-v $PWD/Caddyfile:/etc/caddy/Caddyfile \
2930
-v $PWD:/app \
3031
-p 80:80 -p 443:443/tcp -p 443:443/udp \
3132
--name FrankenPHP-demo \

benchmark.Caddyfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
# This file is only used for benchmarking.
3+
# Please see Caddyfile, for the one that is actual used in this demo
4+
5+
frankenphp {
6+
worker ./public/index.php
7+
}
8+
}
9+
10+
localhost {
11+
route {
12+
root * public/
13+
#php_fastcgi 127.0.0.1:9000
14+
php_server {
15+
try_files {path} index.php
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)