7
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-05-31 21:30:48 +00:00
tutor/tutor/templates/apps/caddy/Caddyfile
Ghassan Maslamani 7d32179038 feat: use encode gzip for caddy
Compressing assests would lead to readuce transfer size.
  As testing with frontend-app-learning/Olive, the network traffic
  before was about ~4MB, after this it became ~1MB.

  This change was suggested by Google Lighthouse[1], there are of
  course more suggestion but this was one the easiest and one of most
  impactful.

  Also check orignal PR overhangio/tutor-mfe/pull/64 for more
  info.
  [1]: https://web.dev/uses-text-compression
2022-10-19 10:46:01 +02:00

68 lines
1.5 KiB
Caddyfile

# Global configuration
{
{{ patch("caddyfile-global")|indent(4) }}
}
# proxy directive snippet (with logging) to be used as follows:
#
# import proxy "containername:port"
(proxy) {
log {
output stdout
format filter {
wrap json
fields {
common_log delete
request>headers delete
resp_headers delete
tls delete
}
}
}
# This will compress requests that matches the default criteria set by Caddy.
# see https://caddyserver.com/docs/caddyfile/directives/encode
# for information about the defaults; i.e. how/when this will be applied.
encode gzip
reverse_proxy {args.0} {
header_up X-Forwarded-Port {{ 443 if ENABLE_HTTPS else 80 }}
}
}
{{ LMS_HOST }}{$default_site_port}, {{ PREVIEW_LMS_HOST }}{$default_site_port} {
@favicon_matcher {
path_regexp ^/favicon.ico$
}
rewrite @favicon_matcher /theming/asset/images/favicon.ico
# Limit profile image upload size
request_body /api/profile_images/*/*/upload {
max_size 1MB
}
request_body {
max_size 4MB
}
import proxy "lms:8000"
{{ patch("caddyfile-lms")|indent(4) }}
}
{{ CMS_HOST }}{$default_site_port} {
@favicon_matcher {
path_regexp ^/favicon.ico$
}
rewrite @favicon_matcher /theming/asset/images/favicon.ico
request_body {
max_size 250MB
}
import proxy "cms:8000"
{{ patch("caddyfile-cms")|indent(4) }}
}
{{ patch("caddyfile") }}