2024-02-27 14:06:19 +00:00
|
|
|
# Caddyfile for Inventree
|
|
|
|
# The following environment variables may be used:
|
|
|
|
# - INVENTREE_SITE_URL: The upstream URL of the Inventree site (default: inventree.localhost)
|
|
|
|
# - INVENTREE_SERVER: The internal URL of the Inventree container (default: http://inventree-server:8000)
|
|
|
|
|
|
|
|
(log_common) {
|
2024-03-13 03:27:26 +00:00
|
|
|
log {
|
|
|
|
output file /var/log/caddy/{args[0]}.access.log
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
(cors-headers) {
|
2024-03-14 12:06:11 +00:00
|
|
|
header Allow GET,HEAD,OPTIONS
|
2024-03-13 03:27:26 +00:00
|
|
|
header Access-Control-Allow-Origin *
|
|
|
|
header Access-Control-Allow-Methods GET,HEAD,OPTIONS
|
2024-03-14 12:06:11 +00:00
|
|
|
header Access-Control-Allow-Headers Authorization,Content-Type,User-Agent
|
2024-03-13 03:27:26 +00:00
|
|
|
|
|
|
|
@cors_preflight{args[0]} method OPTIONS
|
|
|
|
|
|
|
|
handle @cors_preflight{args[0]} {
|
|
|
|
respond "" 204
|
|
|
|
}
|
2024-02-27 14:06:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Change the host to your domain (this will serve at inventree.localhost)
|
|
|
|
{$INVENTREE_SITE_URL:inventree.localhost} {
|
2024-03-13 03:27:26 +00:00
|
|
|
import log_common inventree
|
|
|
|
|
|
|
|
encode gzip
|
|
|
|
|
|
|
|
request_body {
|
|
|
|
max_size 100MB
|
|
|
|
}
|
|
|
|
|
|
|
|
handle_path /static/* {
|
|
|
|
import cors-headers static
|
2024-02-27 14:06:19 +00:00
|
|
|
|
2024-03-13 03:27:26 +00:00
|
|
|
root * /var/www/static
|
|
|
|
file_server
|
|
|
|
}
|
2024-02-27 14:06:19 +00:00
|
|
|
|
2024-03-13 03:27:26 +00:00
|
|
|
handle_path /media/* {
|
|
|
|
import cors-headers media
|
2024-02-27 14:06:19 +00:00
|
|
|
|
2024-03-13 03:27:26 +00:00
|
|
|
root * /var/www/media
|
|
|
|
file_server
|
2024-02-27 14:06:19 +00:00
|
|
|
|
2024-03-13 03:27:26 +00:00
|
|
|
forward_auth {$INVENTREE_SERVER:"http://inventree-server:8000"} {
|
|
|
|
uri /auth/
|
|
|
|
}
|
|
|
|
}
|
2024-02-27 14:06:19 +00:00
|
|
|
|
2024-03-13 03:27:26 +00:00
|
|
|
reverse_proxy {$INVENTREE_SERVER:"http://inventree-server:8000"}
|
2024-02-27 14:06:19 +00:00
|
|
|
}
|