2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-14 19:15:41 +00:00
* Caddyfile updates

- Provide CORS headers for /static/ and /media/

* Adjust config_template

- Make more open by default
This commit is contained in:
Oliver
2024-03-13 14:27:26 +11:00
committed by GitHub
parent 6389493c33
commit 2f852c8aa2
2 changed files with 40 additions and 27 deletions

View File

@ -4,33 +4,50 @@
# - INVENTREE_SERVER: The internal URL of the Inventree container (default: http://inventree-server:8000)
(log_common) {
log {
output file /var/log/caddy/{args.0}.access.log
}
log {
output file /var/log/caddy/{args[0]}.access.log
}
}
(cors-headers) {
header Access-Control-Allow-Origin *
header Access-Control-Allow-Methods GET,HEAD,OPTIONS
header Access-Control-Allow-Headers User-Agent,Content-Type
@cors_preflight{args[0]} method OPTIONS
handle @cors_preflight{args[0]} {
respond "" 204
}
}
# Change the host to your domain (this will serve at inventree.localhost)
{$INVENTREE_SITE_URL:inventree.localhost} {
import log_common inventree
import log_common inventree
encode gzip
encode gzip
request_body {
max_size 100MB
}
request_body {
max_size 100MB
}
handle_path /static/* {
root * /var/www/static
file_server
}
handle_path /static/* {
import cors-headers static
handle_path /media/* {
forward_auth {$INVENTREE_SERVER:"http://inventree-server:8000"} {
uri /auth/
}
root * /var/www/media
file_server
}
root * /var/www/static
file_server
}
reverse_proxy {$INVENTREE_SERVER:"http://inventree-server:8000"}
handle_path /media/* {
import cors-headers media
root * /var/www/media
file_server
forward_auth {$INVENTREE_SERVER:"http://inventree-server:8000"} {
uri /auth/
}
}
reverse_proxy {$INVENTREE_SERVER:"http://inventree-server:8000"}
}