Public Access
39 lines
966 B
Bash
Executable File
39 lines
966 B
Bash
Executable File
#!/usr/bin/env sh
|
|
set -eu
|
|
|
|
OPTIONS_FILE=/data/options.json
|
|
UPSTREAM_URL=$(jq -r '.upstream_url // empty' "$OPTIONS_FILE")
|
|
|
|
case "$UPSTREAM_URL" in
|
|
http://*|https://*) ;;
|
|
*)
|
|
echo "upstream_url must start with http:// or https://" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
UPSTREAM_URL=${UPSTREAM_URL%/}
|
|
|
|
cat > /etc/nginx/conf.d/default.conf <<EOF
|
|
server {
|
|
listen 8099;
|
|
server_name _;
|
|
|
|
location / {
|
|
proxy_pass ${UPSTREAM_URL};
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host \$proxy_host;
|
|
proxy_set_header X-Real-IP \$remote_addr;
|
|
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Host \$host;
|
|
proxy_set_header X-Forwarded-Proto \$scheme;
|
|
proxy_set_header X-Ingress-Path \$http_x_ingress_path;
|
|
proxy_set_header Upgrade \$http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_redirect off;
|
|
}
|
|
}
|
|
EOF
|
|
|
|
exec nginx -g 'daemon off;'
|