Merge pull request #269 from ronivay/feat/proxy-custom-port

feat: add possibility to change proxy listening port
This commit is contained in:
Roni Väyrynen
2024-12-22 15:30:34 +02:00
committed by GitHub
3 changed files with 13 additions and 6 deletions

View File

@@ -176,14 +176,12 @@ deb:
Backup proxy can be used to offload backup tasks from the main Xen Orchestra instance to a proxy which has a direct connection to remote where backups are stored. Backup proxy can be used to offload backup tasks from the main Xen Orchestra instance to a proxy which has a direct connection to remote where backups are stored.
Requirements for proxy VM are otherwise the same as mentioned above, in addition the VM needs to live inside XCP-ng/XenServer pool managed by Xen Orchestra instance and have xen tools installed. VM needs to have access to pool master host and Xen Orchestra needs to be able to access this VM via TCP/443. Requirements for proxy VM are otherwise the same as mentioned above, in addition proxy needs to be able to connect your XCP-ng/XenServer host and Xen Orchestra server needs to be able to access proxy via configured port. By default, it is expected that proxy VM lives inside your XO managed XCP-ng/XenServer pool and XO will figure out the proper connection address with proxy VM's uuid and will use port 443 by default. If you've installed your proxy outside of XCP-ng/XenServer pool and/or you're using some other port, you need to edit the proxy server address from Proxies menu after importing the configuration.
Majority of xo-install.cfg variables have no effect to proxy installation. Proxy process will always run as root user and in port 443. Majority of xo-install.cfg variables have no effect to proxy installation.
Since there is no way in Xen Orchestra from sources to register a proxy via UI, the installation will output a piece of json after the proxy is installed. You need to copy this json string and save to a file. Then use the config import option in Xen Orchestra settings to import this piece of json to add proxy. This works as a partial config import and won't overwrite any existing config. Although it's good to take a config export backup just in case. Since there is no way in Xen Orchestra from sources to register a proxy via UI, the installation will output a piece of json after the proxy is installed. You need to copy this json string and save to a file. Then use the config import option in Xen Orchestra settings to import this piece of json to add proxy. This works as a partial config import and won't overwrite any existing config. Although it's good to take a config export backup just in case.
Xen Orchestra figures out the correct connection address from the VM UUID which is part of this json. This is why the VM needs to be part of pool managed by Xen Orchestra. Connection details cannot be changed manually.
Note that for obvious reasons some of the proxy features seen in Xen Orchestra UI aren't working, like upgrade button, upgrade check, redeploy, update appliance settings. Note that for obvious reasons some of the proxy features seen in Xen Orchestra UI aren't working, like upgrade button, upgrade check, redeploy, update appliance settings.
#### Plugins #### Plugins

View File

@@ -19,6 +19,9 @@
# no effect to Xen Orchestra proxy # no effect to Xen Orchestra proxy
PORT="80" PORT="80"
# Port number to where xo-proxy service is bound
PROXY_PORT="443"
# Base dir for installation and future updates # Base dir for installation and future updates
INSTALLDIR="/opt/xo" INSTALLDIR="/opt/xo"
@@ -28,6 +31,7 @@ SELFUPGRADE=true
# Xen Orchestra configuration file is stored in XOUSER's home directory ($HOME/.config/xo-server/config.toml) and by default will be overwritten with every update done by this script. # Xen Orchestra configuration file is stored in XOUSER's home directory ($HOME/.config/xo-server/config.toml) and by default will be overwritten with every update done by this script.
# You may disable this if you edit configuration by hand and don't want an update to overwrite it. Note that some of the options defined here won't be applied even if changed if this is set to false. # You may disable this if you edit configuration by hand and don't want an update to overwrite it. Note that some of the options defined here won't be applied even if changed if this is set to false.
# This does not apply to proxy installation, proxy config is never overwritten if it already exists!
# options: true/false # options: true/false
# no effect to Xen Orchestra proxy # no effect to Xen Orchestra proxy
CONFIGUPDATE=true CONFIGUPDATE=true

View File

@@ -23,6 +23,7 @@ source "$CONFIG_FILE"
# Set some default variables if sourcing config file fails for some reason # Set some default variables if sourcing config file fails for some reason
SELFUPGRADE=${SELFUPGRADE:-"true"} SELFUPGRADE=${SELFUPGRADE:-"true"}
PORT=${PORT:-80} PORT=${PORT:-80}
PROXY_PORT=${PROXY_PORT:-443}
INSTALLDIR=${INSTALLDIR:-"/opt/xo"} INSTALLDIR=${INSTALLDIR:-"/opt/xo"}
BRANCH=${BRANCH:-"master"} BRANCH=${BRANCH:-"master"}
INCLUDE_V6=${INCLUDE_V6:-"true"} INCLUDE_V6=${INCLUDE_V6:-"true"}
@@ -879,7 +880,7 @@ function VerifyServiceStart {
set -u set -u
if [[ "$XO_SVC" == "xo-proxy" ]]; then if [[ "$XO_SVC" == "xo-proxy" ]]; then
local PORT="443" local PORT="$PROXY_PORT"
fi fi
PROXY_CONFIG_UPDATED=${PROXY_CONFIG_UPDATED:-"false"} PROXY_CONFIG_UPDATED=${PROXY_CONFIG_UPDATED:-"false"}
@@ -1052,7 +1053,7 @@ EOF
printinfo "Reloading systemd configuration" printinfo "Reloading systemd configuration"
runcmd "/bin/systemctl daemon-reload" runcmd "/bin/systemctl daemon-reload"
# if xen orchestra proxy configuration file doesn't exist or configuration update is not disabled in xo-install.cfg, we create it # if xen orchestra proxy configuration file doesn't exist we create it here
if [[ ! -f "$CONFIGPATH_PROXY/.config/xo-proxy/config.toml" ]]; then if [[ ! -f "$CONFIGPATH_PROXY/.config/xo-proxy/config.toml" ]]; then
PROXY_VM_UUID="$(dmidecode -t system | grep UUID | awk '{print $NF}')" PROXY_VM_UUID="$(dmidecode -t system | grep UUID | awk '{print $NF}')"
@@ -1067,6 +1068,10 @@ EOF
printinfo "Adding authentication token to xo-proxy config" printinfo "Adding authentication token to xo-proxy config"
runcmd "sed -i \"s/^authenticationToken = .*/authenticationToken = '$PROXY_TOKEN'/\" $CONFIGPATH_PROXY/.config/xo-proxy/config.toml" runcmd "sed -i \"s/^authenticationToken = .*/authenticationToken = '$PROXY_TOKEN'/\" $CONFIGPATH_PROXY/.config/xo-proxy/config.toml"
if [[ "$PROXY_PORT" != "443" ]]; then
printinfo "Updating proxy port config"
runcmd "sed -i \"s/port = 443/port = $PROXY_PORT/\" $CONFIGPATH_PROXY/.config/xo-proxy/config.toml"
fi
fi fi
echo echo