UI delivery, stage B: single CSP with optional connect-src origins (OVPMON_CSP_CONNECT_EXTRA)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5.5 committed 2026-10-07 13:28:30 +03:00
1 parent d38acd74de
commit d5e83eaff5
13 files changed
+211 -17

No files matched your search

+2 -1
View File
@@ -47,6 +47,7 @@ COPY APP_PROFILER /app/APP_PROFILER
# UI and nginx: the template is rendered at container start (entrypoint.sh)
COPY --from=ui-build /app/dist /usr/share/nginx/html
COPY APP_UI/default.conf.template /etc/ovpmon/default.conf.template
COPY APP_UI/check-csp-connect-extra.sh /usr/local/bin/ovpmon-check-csp.sh
RUN rm -f /etc/nginx/http.d/default.conf \
&& mkdir -p /run/nginx /var/log/nginx \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
@@ -56,7 +57,7 @@ COPY deploy/allinone/supervisord.conf /etc/supervisord.conf
COPY deploy/allinone/entrypoint.sh /usr/local/bin/ovpmon-entrypoint.sh
# Mount points of the five data volumes and of the backup packages volume (ovp_backups)
RUN chmod +x /usr/local/bin/ovpmon-entrypoint.sh \
RUN chmod +x /usr/local/bin/ovpmon-entrypoint.sh /usr/local/bin/ovpmon-check-csp.sh \
&& mkdir -p /app/db /app/easy-rsa /app/client-config /app/backups /etc/openvpn /var/log/openvpn
# Default database locations (the compose file sets the same values)
+12 -3
View File
@@ -71,11 +71,20 @@ ensure_rule mangle FORWARD -o "$NAT_IFACE" -p tcp --tcp-flags SYN,RST SYN -j TCP
ensure_rule mangle FORWARD -i "$NAT_IFACE" -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
# --- 5. Nginx configuration ---------------------------------------------------------------
# The same template as the UI image of variant B; all upstreams are local. Only the four
# OVP_* variables are substituted, nginx's own $variables stay intact.
# The same template as the UI image of variant B; all upstreams are local. Only the OVP_* variables
# are substituted, nginx's own $variables stay intact.
# OVP_CSP_CONNECT_EXTRA (compose: OVPMON_CSP_CONNECT_EXTRA): extra connect-src origins of the CSP. It goes into
# a response header, so only origins are accepted (APP_UI/check-csp-connect-extra.sh, copied into the image):
# anything else could inject another CSP directive.
# Empty value: same origin only.
OVP_CSP_CONNECT_EXTRA="${OVP_CSP_CONNECT_EXTRA:-}"
/usr/local/bin/ovpmon-check-csp.sh || die "invalid OVPMON_CSP_CONNECT_EXTRA (see above)"
# one space between origins (the template has the value after 'self' and a space)
OVP_CSP_CONNECT_EXTRA=$(printf '%s' "$OVP_CSP_CONNECT_EXTRA" | tr -s ' ')
export OVP_CSP_CONNECT_EXTRA
export OVP_API_HOST=127.0.0.1 OVP_API_PORT=5001
export OVP_PROFILER_HOST=127.0.0.1 OVP_PROFILER_PORT=8000
envsubst '${OVP_API_HOST} ${OVP_API_PORT} ${OVP_PROFILER_HOST} ${OVP_PROFILER_PORT}' \
envsubst '${OVP_API_HOST} ${OVP_API_PORT} ${OVP_PROFILER_HOST} ${OVP_PROFILER_PORT} ${OVP_CSP_CONNECT_EXTRA}' \
< /etc/ovpmon/default.conf.template > /etc/nginx/http.d/ovpmon.conf
nginx -t || die "generated nginx configuration is invalid (see above)"