mirror of https://github.com/ekimekim/wubloader
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
Bash
49 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
# This script expects a mapping of services and ports in the SERVICES env var,
|
|
# with one line per service containing "NAME PORT".
|
|
|
|
# Other vars:
|
|
# THRIMBLETRIMMER: Set non-empty to also serve thrimbletrimmer on /thrimbletrimmer
|
|
# SEGMENTS: Set to path to segments dir to also serve segments dir on /segments
|
|
|
|
generate_location() {
|
|
# generate_location PATH URL
|
|
echo -e "\t\tlocation $1 { proxy_pass $2; }"
|
|
}
|
|
|
|
LOCATIONS=$(
|
|
[ -n "$SERVICES" ] && echo "$SERVICES" | while read name port; do
|
|
# restreamer is the catch-all
|
|
[ "$name" == "restreamer" ] && generate_location / "http://restreamer:$port"
|
|
# thrimshim takes any calls to thrimshim/
|
|
[ "$name" == "thrimshim" ] && generate_location /thrimshim "http://thrimshim:$port"
|
|
# all services have metrics under /metrics/SERVICE, except for thrimebletrimmer
|
|
generate_location "/metrics/$name" "http://$name:$port/metrics"
|
|
done
|
|
[ -n "$THRIMBLETRIMMER" ] &&
|
|
echo -e "\t\tlocation = / { return 301 /thrimbletrimmer/dashboard.html; }" &&
|
|
echo -e "\t\tlocation /thrimbletrimmer { }"
|
|
[ -n "$SEGMENTS" ] &&
|
|
echo -e "\t\tlocation /segments/ { alias $SEGMENTS/; }"
|
|
)
|
|
|
|
cat > /etc/nginx/nginx.conf <<EOF
|
|
worker_processes 1;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
include /etc/nginx/mime.types;
|
|
server {
|
|
listen 80;
|
|
gzip on;
|
|
gzip_comp_level 9;
|
|
absolute_redirect off;
|
|
$LOCATIONS
|
|
}
|
|
}
|
|
EOF
|