mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-18 05:34:20 +01:00
Update nginx (#662)
This commit is contained in:
45
nginx_proxy/data/run.sh
Executable file
45
nginx_proxy/data/run.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/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)
|
||||
HSTS=$(jq --raw-output ".hsts // empty" $CONFIG_PATH)
|
||||
CUSTOMIZE_ACTIVE=$(jq --raw-output ".customize.active" $CONFIG_PATH)
|
||||
|
||||
# Generate dhparams
|
||||
if [ ! -f "$DHPARAMS_PATH" ]; then
|
||||
echo "[INFO] Generating dhparams (this will take some time)..."
|
||||
openssl dhparam -dsaparam -out "$DHPARAMS_PATH" 4096 > /dev/null
|
||||
fi
|
||||
|
||||
if [ ! -f "$SNAKEOIL_CERT" ]; then
|
||||
echo "[INFO] Creating '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
|
||||
|
||||
[ -n "$HSTS" ] && HSTS="add_header Strict-Transport-Security \"$HSTS\";"
|
||||
sed -i "s/%%HSTS%%/$HSTS/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] Running nginx..."
|
||||
exec nginx -c /etc/nginx.conf < /dev/null
|
||||
Reference in New Issue
Block a user