mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-17 05:04:21 +01:00
* nginx_proxy: Allow customization with included config files from /share Provides a way to add additional configuration to the default, for example proxy_pass locations before the default root location, as well as additional complete server configs. * nginx_proxy: Run logo.png through zopflipng -m * nginx_proxy: Bump version to 1.0, add CHANGELOG.md * Update CHANGELOG.md
42 lines
1.4 KiB
Bash
42 lines
1.4 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
CONFIG_PATH=/data/options.json
|
|
DHPARAMS_PATH=/data/dhparams.pem
|
|
|
|
SNAKEOIL_CERT=/data/ssl-cert-snakeoil.pem
|
|
SNAKEOIL_KEY=/data/ssl-cert-snakeoil.key
|
|
|
|
DOMAIN=$(jq --raw-output ".domain" $CONFIG_PATH)
|
|
KEYFILE=$(jq --raw-output ".keyfile" $CONFIG_PATH)
|
|
CERTFILE=$(jq --raw-output ".certfile" $CONFIG_PATH)
|
|
CUSTOMIZE_ACTIVE=$(jq --raw-output ".customize.active" $CONFIG_PATH)
|
|
|
|
# Generate dhparams
|
|
if [ ! -f "$DHPARAMS_PATH" ]; then
|
|
echo "[INFO] Generate dhparams..."
|
|
openssl dhparam -dsaparam -out "$DHPARAMS_PATH" 4096 > /dev/null
|
|
fi
|
|
|
|
if [ ! -f "$SNAKEOIL_CERT" ]; then
|
|
echo "[INFO] Create snakeoil (self-signed certificate)"
|
|
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout $SNAKEOIL_KEY -out $SNAKEOIL_CERT -subj '/CN=localhost'
|
|
fi
|
|
|
|
# Prepare config file
|
|
sed -i "s/%%FULLCHAIN%%/$CERTFILE/g" /etc/nginx.conf
|
|
sed -i "s/%%PRIVKEY%%/$KEYFILE/g" /etc/nginx.conf
|
|
sed -i "s/%%DOMAIN%%/$DOMAIN/g" /etc/nginx.conf
|
|
|
|
# Allow customize configs from share
|
|
if [ "$CUSTOMIZE_ACTIVE" == "true" ]; then
|
|
CUSTOMIZE_DEFAULT=$(jq --raw-output ".customize.default" $CONFIG_PATH)
|
|
sed -i "s|#include /share/nginx_proxy_default.*|include /share/$CUSTOMIZE_DEFAULT;|" /etc/nginx.conf
|
|
CUSTOMIZE_SERVERS=$(jq --raw-output ".customize.servers" $CONFIG_PATH)
|
|
sed -i "s|#include /share/nginx_proxy/.*|include /share/$CUSTOMIZE_SERVERS;|" /etc/nginx.conf
|
|
fi
|
|
|
|
# start server
|
|
echo "[INFO] Run nginx"
|
|
exec nginx -c /etc/nginx.conf < /dev/null
|