🗃️ Update codebase 🗃️
All checks were successful
release-tag / release-image (push) Successful in 5m30s

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
This commit is contained in:
casjay
2025-11-21 09:35:41 -05:00
parent a69f03b0a4
commit b438368de6
3 changed files with 18 additions and 12 deletions

View File

@@ -4,8 +4,8 @@
#Reverse Proxy #Reverse Proxy
#See /etc/nginx/conf.d/default.conf for proxy servers #See /etc/nginx/conf.d/default.conf for proxy servers
server { server {
server_name REPLACE_ONION_SITE;
listen REPLACE_ONION_PORT; listen REPLACE_ONION_PORT;
server_name REPLACE_ONION_SITE;
keepalive_timeout 75 75; keepalive_timeout 75 75;
access_log /data/logs/nginx/access.REPLACE_ONION_SITE.log; access_log /data/logs/nginx/access.REPLACE_ONION_SITE.log;
error_log /data/logs/nginx/error.REPLACE_ONION_SITE.log info; error_log /data/logs/nginx/error.REPLACE_ONION_SITE.log info;

View File

@@ -191,6 +191,7 @@ CMD_ENV=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Per Application Variables or imports # Per Application Variables or imports
TOR_DNS_ENABLED="${TOR_DNS_ENABLED:-yes}" 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_RELAY_ENABLED="${TOR_RELAY_ENABLED:-yes}"
TOR_BRIDGE_ENABLED="${TOR_BRIDGE_ENABLED:-yes}" TOR_BRIDGE_ENABLED="${TOR_BRIDGE_ENABLED:-yes}"
TOR_HIDDEN_ENABLED="${TOR_HIDDEN_ENABLED:-yes}" TOR_HIDDEN_ENABLED="${TOR_HIDDEN_ENABLED:-yes}"
@@ -282,7 +283,7 @@ HashedControlPassword 16:C30604D1D90F341360A14D9A1048C1DF4A3CA2411444E52EE5B954C
##### bandwidth and accounting (monitoring only) ##### bandwidth and accounting (monitoring only)
Nickname ${TOR_SERVER_NICK_NAME:-$RANDOM_NICK} Nickname ${TOR_SERVER_NICK_NAME:-$RANDOM_NICK}
ContactInfo ${TOR_SERVER_ADMIN:-tor-admin@$HOSTNAME} 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 AccountingStart month 1 00:00
##### directiories and files ##### directiories and files
@@ -333,6 +334,11 @@ EOF
mkdir -p "$CONF_DIR/hidden.d" mkdir -p "$CONF_DIR/hidden.d"
mkdir -p "$TOR_HIDDEN_SERVICE_DIR/default" mkdir -p "$TOR_HIDDEN_SERVICE_DIR/default"
chmod -f 700 "$TOR_HIDDEN_SERVICE_DIR/default" chmod -f 700 "$TOR_HIDDEN_SERVICE_DIR/default"
if ! grep -shq "" ""; then
cat <<EOF >>"$CONF_DIR/server.conf"
%include $CONF_DIR/hidden.d/*.conf
EOF
fi
for HiddenService in $CONF_DIR/hidden.d/*.conf; do for HiddenService in $CONF_DIR/hidden.d/*.conf; do
HiddenServiceDir="$(grep -si '^HiddenServiceDir ' "$HiddenService" | awk '{print $2}' 2>/dev/null)" HiddenServiceDir="$(grep -si '^HiddenServiceDir ' "$HiddenService" | awk '{print $2}' 2>/dev/null)"
if [ -n "$HiddenServiceDir" ]; then if [ -n "$HiddenServiceDir" ]; then
@@ -340,11 +346,10 @@ EOF
chmod 700 "$HiddenServiceDir" 2>/dev/null chmod 700 "$HiddenServiceDir" 2>/dev/null
fi fi
done done
cat <<EOF >>"$CONF_DIR/server.conf" cat <<EOF >"$CONF_DIR/hidden.d/default.conf"
#### hidden services #### hidden services
HiddenServiceDir $TOR_HIDDEN_SERVICE_DIR/default HiddenServiceDir $TOR_HIDDEN_SERVICE_DIR/default
HiddenServicePort ${TOR_HIDDEN_SERVICE_PORT:-80 127.0.0.1:80} HiddenServicePort ${TOR_HIDDEN_SERVICE_PORT:-80 $TOR_HIDDEN_IP:80}
%include $CONF_DIR/hidden.d/*.conf
EOF EOF
fi fi

View File

@@ -171,7 +171,8 @@ user_pass="${NGINX_USER_PASS_WORD:-}" # normal user password
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Additional variables # 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 # Specifiy custom directories to be created
ADD_APPLICATION_FILES="" ADD_APPLICATION_FILES=""
@@ -279,12 +280,9 @@ __update_conf_files() {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# define actions # define actions
while :; do while :; do
sleep 30 [ -d "/run/tor/sites" ] && sites="$(ls -A /run/tor/sites/* 2>/dev/null | wc -l)"
echo "The nginx server is waiting for tor to start" 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
sites="$(ls -A /run/tor/sites/* 2>/dev/null | wc -l)"
if [ ! -f "/tmp/init_tor_services" ]; then break; fi
done done
echo "The tor server seems to have started"
if [ "$sites" -eq 0 ]; then if [ "$sites" -eq 0 ]; then
echo "No onion sites found in /run/tor/sites" >&2 echo "No onion sites found in /run/tor/sites" >&2
else else
@@ -307,8 +305,8 @@ __update_conf_files() {
cp -Rf "/config/nginx/vhosts.d/template" "/config/nginx/vhosts.d/$onion_site.onion.conf" cp -Rf "/config/nginx/vhosts.d/template" "/config/nginx/vhosts.d/$onion_site.onion.conf"
fi fi
if [ -f "/config/nginx/vhosts.d/$onion_site.onion.conf" ]; then 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_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" sed -i 's|REPLACE_ONION_WWW_DIR|/data/htdocs/onions/'$onion_site'|g' "/config/nginx/vhosts.d/$onion_site.onion.conf"
fi fi
if [ -f "/data/htdocs/onions/$onion_site/index.html" ]; then 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_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" sed -i 's|REPLACE_ONION_WWW_DIR|/data/htdocs/onions/'$onion_site'|g' "/data/htdocs/onions/$onion_site/index.html"
fi 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" echo "Created $onion_site.onion in /data/htdocs/onions/$onion_site"
done done
fi fi