Caddy v2 Configuration

A quick information in case you search a reverse proxy using Caddy instead of Apache or Nginx

here the caddy file
(common) {
header /* {
-Server
# keep referrer data off of HTTP connections
Referrer-Policy no-referrer-when-downgrade
# Referrer-Policy “strict-origin-when-cross-origin”
# enable HSTS
Strict-Transport-Security “max-age=31536000; includeSubDomains; preload”
# Enable cross-site filter (XSS) and tell browser to block detected attacks
X-Xss-Protection “1; mode=block”
# disable clients from sniffing the media type
X-Content-Type-Options nosniff
# clickjacking protection
X-Frame-Options “SAMEORIGIN”
}
}
(cors) {
@cors_preflight method OPTIONS
@cors header Origin {args.0}

handle @cors_preflight {
header Access-Control-Allow-Origin “{args.0}”
header Access-Control-Allow-Methods “GET, POST, PUT, PATCH, DELETE”
header Access-Control-Allow-Headers “Content-Type”
header Access-Control-Max-Age “3600”
respond “” 204
}

handle @cors {
header Access-Control-Allow-Origin “{args.0}”
header Access-Control-Expose-Headers “Link”
}
}

(certificate) {
tls # your certificate + key
}

janus.xxx.xxx { #your server
#log {
# output stdout
# }
import certificate
import common
file_server
encode zstd gzip
#php_fastcgi unix//run/php/php8.2-fpm.sock #your php version if you are hosting a php server on Janus
route /janus/* {
uri strip_prefix /janus
reverse_proxy https://127.0.0.1:8089
}
route /admin/* {
uri strip_prefix /admin
reverse_proxy https://127.0.0.1:7889
}
route /janus-ws/* {
uri strip_prefix /janus-ws
reverse_proxy ws://127.0.0.1:8188
}
route /janus-wss/* {
uri strip_prefix /janus-wss
reverse_proxy wss://127.0.0.1:8989
}
root * /var/www/janus-gateway/html #if you host the demos files here
}