File tree Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Original file line number Diff line number Diff line change 11
11
max_size {$TEKST_MAX_REQ_SIZE:250 MB}
12
12
}
13
13
14
+ # redirect root requests to use trailing slash
15
+ @root expression {path} == "{$TEKST_WEB_PATH}"
16
+ redir @root {$TEKST_WEB_PATH} /
17
+
14
18
# redirect API requests to use trailing slash
15
- redir /api /api/
19
+ redir {$TEKST_WEB_PATH} /api {$TEKST_WEB_PATH} /api/
16
20
17
21
# proxy all API requests to API app
18
- handle_path /api/* {
22
+ handle_path {$TEKST_WEB_PATH} /api/* {
19
23
reverse_proxy http://127.0.0.1:8000
20
24
}
21
25
22
26
# serve static files (custom assets)
23
- handle_path /static/* {
27
+ handle_path {$TEKST_WEB_PATH} /static/* {
24
28
root * /var/www/tekst/static
25
29
file_server
26
30
}
27
31
28
32
# help browsers to find the custom favicon at root
29
33
# (ofc this only works if the app is served at root path "/")
30
- handle_path /favicon.ico {
31
- root * /var/www/tekst/static
34
+ handle_path {$TEKST_WEB_PATH} /favicon.ico {
35
+ root /var/www/tekst/static/favicon.ico
32
36
file_server
33
37
}
34
38
35
39
# serve web client files
36
- handle_path /* {
40
+ handle_path {$TEKST_WEB_PATH} /* {
37
41
root * /var/www/html
38
42
try_files {path} /index.html
39
43
file_server
Original file line number Diff line number Diff line change 1
- #! /bin/sh
1
+ #! /bin/sh -e
2
2
3
3
# run DB migration if arg #1 is "migrate"
4
- if [ " $1 " = " migrate" ]; then
4
+ if [[ " $1 " == " migrate" ] ]; then
5
5
python3 -m tekst migrate
6
6
exit $?
7
- fi ;
7
+ fi
8
8
9
9
# run bootstrapping routine first
10
10
python3 -m tekst bootstrap
11
- test $? -ne 0 && exit 1
12
11
13
12
# remove (all) trailing slashes from TEKST_WEB_PATH
14
13
TEKST_WEB_PATH=$( echo " $TEKST_WEB_PATH " | sed ' s|/*$||' )
14
+
15
15
# remove existing base tag from client's index.html, if any
16
- sed -i ' s|< base href=".*">||g ' /var/www/html/ index.html
17
- # inject base tag with base URL into client's index.html
18
- sed -i ' s|<head>|<head>< base href="' " $TEKST_WEB_PATH " ' / " />|g ' /var/www/html/index.html
16
+ # and inject base tag with base URL into client's index.html
17
+ sed -Ei /var/www/html/index.html -e ' s|< base [^>]+>|| ' \
18
+ -e ' s|<head>|\0< base href="' " $TEKST_WEB_PATH / " ' " />|'
19
19
20
20
# start caddy (will detach and run in background after startup)
21
21
caddy start --config /etc/caddy/Caddyfile
You can’t perform that action at this time.
0 commit comments