From b438368de6ed94fa68b02274c572341e98f52958 Mon Sep 17 00:00:00 2001 From: casjay Date: Fri, 21 Nov 2025 09:35:41 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Update=20codebase=20?= =?UTF-8?q?=F0=9F=97=83=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rootfs/tmp/etc/nginx/vhosts.d/template rootfs/usr/local/etc/docker/init.d/03-tor-server.sh rootfs/usr/local/etc/docker/init.d/zz-nginx.sh --- rootfs/tmp/etc/nginx/vhosts.d/template | 2 +- .../usr/local/etc/docker/init.d/03-tor-server.sh | 13 +++++++++---- rootfs/usr/local/etc/docker/init.d/zz-nginx.sh | 15 ++++++++------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/rootfs/tmp/etc/nginx/vhosts.d/template b/rootfs/tmp/etc/nginx/vhosts.d/template index 3ed4411..8ba64bb 100644 --- a/rootfs/tmp/etc/nginx/vhosts.d/template +++ b/rootfs/tmp/etc/nginx/vhosts.d/template @@ -4,8 +4,8 @@ #Reverse Proxy #See /etc/nginx/conf.d/default.conf for proxy servers server { - server_name REPLACE_ONION_SITE; listen REPLACE_ONION_PORT; + server_name REPLACE_ONION_SITE; keepalive_timeout 75 75; access_log /data/logs/nginx/access.REPLACE_ONION_SITE.log; error_log /data/logs/nginx/error.REPLACE_ONION_SITE.log info; diff --git a/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh b/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh index c16188e..028aa5d 100755 --- a/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh +++ b/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh @@ -191,6 +191,7 @@ CMD_ENV="" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Per Application Variables or imports TOR_DNS_ENABLED="${TOR_DNS_ENABLED:-yes}" +TOR_HIDDEN_IP="${TOR_HIDDEN_IP:-127.0.0.1}" TOR_RELAY_ENABLED="${TOR_RELAY_ENABLED:-yes}" TOR_BRIDGE_ENABLED="${TOR_BRIDGE_ENABLED:-yes}" TOR_HIDDEN_ENABLED="${TOR_HIDDEN_ENABLED:-yes}" @@ -282,7 +283,7 @@ HashedControlPassword 16:C30604D1D90F341360A14D9A1048C1DF4A3CA2411444E52EE5B954C ##### bandwidth and accounting (monitoring only) Nickname ${TOR_SERVER_NICK_NAME:-$RANDOM_NICK} ContactInfo ${TOR_SERVER_ADMIN:-tor-admin@$HOSTNAME} -AccountingMax ${TOR_SERVER_ACCOUNT_MAX:-250 GBytes} +AccountingMax ${TOR_SERVER_ACCOUNT_MAX:-500 GBytes} AccountingStart month 1 00:00 ##### directiories and files @@ -333,6 +334,11 @@ EOF mkdir -p "$CONF_DIR/hidden.d" mkdir -p "$TOR_HIDDEN_SERVICE_DIR/default" chmod -f 700 "$TOR_HIDDEN_SERVICE_DIR/default" + if ! grep -shq "" ""; then + cat <>"$CONF_DIR/server.conf" +%include $CONF_DIR/hidden.d/*.conf +EOF + fi for HiddenService in $CONF_DIR/hidden.d/*.conf; do HiddenServiceDir="$(grep -si '^HiddenServiceDir ' "$HiddenService" | awk '{print $2}' 2>/dev/null)" if [ -n "$HiddenServiceDir" ]; then @@ -340,11 +346,10 @@ EOF chmod 700 "$HiddenServiceDir" 2>/dev/null fi done - cat <>"$CONF_DIR/server.conf" + cat <"$CONF_DIR/hidden.d/default.conf" #### hidden services HiddenServiceDir $TOR_HIDDEN_SERVICE_DIR/default -HiddenServicePort ${TOR_HIDDEN_SERVICE_PORT:-80 127.0.0.1:80} -%include $CONF_DIR/hidden.d/*.conf +HiddenServicePort ${TOR_HIDDEN_SERVICE_PORT:-80 $TOR_HIDDEN_IP:80} EOF fi diff --git a/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh b/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh index 0b70a62..9a51684 100755 --- a/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh +++ b/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh @@ -171,7 +171,8 @@ user_pass="${NGINX_USER_PASS_WORD:-}" # normal user password # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Additional variables -TOR_HIDDEN_SERVICE_DIR="${TOR_HIDDEN_SERVICE_DIR:-$DATA_DIR/hidden}" +TOR_HIDDEN_IP="${TOR_HIDDEN_IP:-}" +TOR_HIDDEN_SERVICE_DIR="${TOR_HIDDEN_SERVICE_DIR:-/data/tor/server/hidden}" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Specifiy custom directories to be created ADD_APPLICATION_FILES="" @@ -279,12 +280,9 @@ __update_conf_files() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # define actions while :; do - sleep 30 - echo "The nginx server is waiting for tor to start" - sites="$(ls -A /run/tor/sites/* 2>/dev/null | wc -l)" - if [ ! -f "/tmp/init_tor_services" ]; then break; fi + [ -d "/run/tor/sites" ] && sites="$(ls -A /run/tor/sites/* 2>/dev/null | wc -l)" + if [ ! -f "/tmp/init_tor_services" ]; then echo "The tor server seems to have started" && break; else echo "The nginx server is waiting for tor to start" && sleep 30; fi done - echo "The tor server seems to have started" if [ "$sites" -eq 0 ]; then echo "No onion sites found in /run/tor/sites" >&2 else @@ -307,8 +305,8 @@ __update_conf_files() { cp -Rf "/config/nginx/vhosts.d/template" "/config/nginx/vhosts.d/$onion_site.onion.conf" fi if [ -f "/config/nginx/vhosts.d/$onion_site.onion.conf" ]; then - sed -i 's|REPLACE_ONION_PORT|'$SERVICE_PORT'|g' "/config/nginx/vhosts.d/$onion_site.onion.conf" sed -i 's|REPLACE_ONION_SITE|'$onion_site.onion'|g' "/config/nginx/vhosts.d/$onion_site.onion.conf" + sed -i 's|REPLACE_ONION_PORT|'$TOR_HIDDEN_IP:$SERVICE_PORT'|g' "/config/nginx/vhosts.d/$onion_site.onion.conf" sed -i 's|REPLACE_ONION_WWW_DIR|/data/htdocs/onions/'$onion_site'|g' "/config/nginx/vhosts.d/$onion_site.onion.conf" fi if [ -f "/data/htdocs/onions/$onion_site/index.html" ]; then @@ -316,6 +314,9 @@ __update_conf_files() { sed -i 's|REPLACE_DEFAULT_TOR_ADDRESS|'$onion_site'|g' "/data/htdocs/onions/$onion_site/index.html" sed -i 's|REPLACE_ONION_WWW_DIR|/data/htdocs/onions/'$onion_site'|g' "/data/htdocs/onions/$onion_site/index.html" fi + if [ "$TOR_HIDDEN_IP" = "0.0.0.0" ] || [ -z "$TOR_HIDDEN_IP" ]; then + sed -i 's|'$TOR_HIDDEN_IP:$SERVICE_PORT'|'$SERVICE_PORT'|g' "/config/nginx/vhosts.d/$onion_site.onion.conf" + fi echo "Created $onion_site.onion in /data/htdocs/onions/$onion_site" done fi