Added trustedproxy to dynamic config feature.
Daan Selen committed
Mar 25, 2025 at 15:12 UTC
db7eacbca31332c47e5c1c66590602f0dff24575
2 files changed
+24
-4
docker/Dockerfile
+1
-1
@@ -58,7 +58,7 @@ ENV REGEN_SESSIONKEY="false"
58
ENV REVERSE_PROXY=""
59
ENV REVERSE_PROXY_TLS_PORT="443"
60
ENV WEBRTC="false"
61
-
61
+ENV TRUSTED_PROXY=""
62
63
# MongoDB Variables
64
ARG INCLUDE_MONGODB_TOOLS="false"
docker/entrypoint.sh
+23
-3
@@ -106,7 +106,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
106
fi
107
108
# HOSTNAME
109
- if [[ -n $HOSTNAME ]] && [[ $HOSTNAME =~ ^[a-zA-Z0-9-]+$ ]]; then
109
+ if [[ -n $HOSTNAME ]]; then
110
echo "Setting hostname (cert)... $HOSTNAME"
111
112
jq --arg hostname "$HOSTNAME" \
@@ -159,6 +159,26 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
159
sed -i 's/"AllowFraming":/"_AllowFraming":/g' "$CONFIG_FILE"
160
fi
161
162
+ # trustedProxy
163
+ if [[ -n $TRUSTED_PROXY ]]; then
164
+ echo "Setting trustedProxy... - $REVERSE_PROXY_STRING"
165
+
166
+ if [[ $TRUSTED_PROXY == "all" ]]; then
167
+ sed -i 's/"_trustedProxy"/"trustedProxy"/' "$CONFIG_FILE"
168
+ jq --argjson trusted_proxy "true" \
169
+ '.settings.trustedProxy = $trusted_proxy' \
170
+ "$CONFIG_FILE" > temp_config.json && mv temp_config.json "$CONFIG_FILE"
171
+ else
172
+ sed -i 's/"_trustedProxy"/"trustedProxy"/' "$CONFIG_FILE"
173
+ jq --argjson trusted_proxy "$TRUSTED_PROXY" \
174
+ '.settings.trustedProxy = $trusted_proxy' \
175
+ "$CONFIG_FILE" > temp_config.json && mv temp_config.json "$CONFIG_FILE"
176
+ fi
177
+ else
178
+ echo "Invalid or no REVERSE_PROXY and/or REVERSE_PROXY_TLS_PORT value given, commenting out so default applies... Value(s) given: $REVERSE_PROXY_STRING"
179
+ sed -i 's/"certUrl":/"_certUrl":/g' "$CONFIG_FILE"
180
+ fi
181
+
182
# ALLOW_NEW_ACCOUNTS
183
if [[ -n $ALLOW_NEW_ACCOUNTS ]] && [[ $ALLOW_NEW_ACCOUNTS =~ ^(true|false)$ ]]; then
184
echo "Setting NewAccounts... $ALLOW_NEW_ACCOUNTS"
@@ -190,7 +210,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
210
echo "Setting minify... $MINIFY"
211
212
sed -i 's/"_minify"/"minify"/' "$CONFIG_FILE"
193
- jq --arg minify "$MINIFY" \
213
+ jq --argjson minify "$MINIFY" \
214
'.domains[""].minify = $minify' \
215
"$CONFIG_FILE" > temp_config.json && mv temp_config.json "$CONFIG_FILE"
216
#sed -i "s/\"minify\": *[a-z]*/\"minify\": $MINIFY/" "$CONFIG_FILE"
@@ -204,7 +224,7 @@ if [[ "$DYNAMIC_CONFIG" =~ ^(true|yes)$ ]]; then
224
echo "Setting allowedOrigin... $ALLOWED_ORIGIN"
225
226
sed -i 's/"_allowedOrigin"/"allowedOrigin"/' "$CONFIG_FILE"
207
- jq --arg allowed_origin "$ALLOWED_ORIGIN" \
227
+ jq --argjson allowed_origin "$ALLOWED_ORIGIN" \
228
'.domains[""].allowedOrigin = $allowed_origin' \
229
"$CONFIG_FILE" > temp_config.json && mv temp_config.json "$CONFIG_FILE"
230
else