Merge pull request #372 from m0canu1/add-reverse-proxy-options

Add reverse proxy options to generated XO configuration
This commit is contained in:
Roni Väyrynen
2026-10-07 10:55:06 +03:00
committed by GitHub
2 changed files with 31 additions and 0 deletions

View File

@@ -41,6 +41,19 @@ SELFUPGRADE=true
# no effect to Xen Orchestra proxy
CONFIGUPDATE=true
# Public URL used to access Xen Orchestra through a domain name or reverse proxy.
#PUBLIC_URL=""
# Trust X-Forwarded-* headers sent by a reverse proxy.
# Enable only if xo-server is not directly reachable by untrusted clients.
# options: true/false
#USE_FORWARDED_HEADERS="false"
# Set the Secure attribute on XO session cookies.
# Enable when HTTPS is terminated by a reverse proxy.
# options: true/false
#COOKIE_SECURE="false"
# Location of Xen Orchestra repository where source code is fetched
REPOSITORY="https://github.com/vatesfr/xen-orchestra"

View File

@@ -53,6 +53,9 @@ INSTALL_REPOS="${INSTALL_REPOS:-"true"}"
SYSLOG_TARGET="${SYSLOG_TARGET:-""}"
YARN_CACHE_CLEANUP="${YARN_CACHE_CLEANUP:-"false"}"
YARN_NETWORK_TIMEOUT="${YARN_NETWORK_TIMEOUT:-"300000"}"
PUBLIC_URL="${PUBLIC_URL:-""}"
USE_FORWARDED_HEADERS="${USE_FORWARDED_HEADERS:-"false"}"
COOKIE_SECURE="${COOKIE_SECURE:-"false"}"
# set variables not changeable in configfile
TIME=$(date +%Y%m%d%H%M)
@@ -824,6 +827,21 @@ function InstallXO {
runcmd "sed -i \"/^\[logs.transport.syslog.*/a target = '$SYSLOG_TARGET'\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
fi
if [[ -n "$PUBLIC_URL" ]]; then
printinfo "Setting public URL in xo-server configuration file"
runcmd "sed -i \"/^#publicUrl =.*/a publicUrl = '$PUBLIC_URL'\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
fi
if [[ "$USE_FORWARDED_HEADERS" == "true" ]]; then
printinfo "Trusting forwarded headers in xo-server configuration file"
runcmd "sed -i \"s/#useForwardedHeaders = true/useForwardedHeaders = true/\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
fi
if [[ "$COOKIE_SECURE" == "true" ]]; then
printinfo "Enabling secure cookies in xo-server configuration file"
runcmd "sed -i \"/^\[http.cookies\]/a secure = true\" $INSTALLDIR/xo-builds/xen-orchestra-$TIME/packages/xo-server/sample.config.toml"
fi
printinfo "Activating modified configuration file"
if ! [[ -d $CONFIGPATH/.config ]]; then
# create generic .config directory only if it doesn't exist as we set permissions to it