mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-1005: Merge Docker support for configuring RemoteIPValve.
This commit is contained in:
@@ -50,6 +50,11 @@ RUN /opt/guacamole/bin/build-guacamole.sh "$BUILD_DIR" /opt/guacamole "$BUILD_PR
|
|||||||
# For the runtime image, we start with the official Tomcat distribution
|
# For the runtime image, we start with the official Tomcat distribution
|
||||||
FROM tomcat:${TOMCAT_VERSION}-${TOMCAT_JRE}
|
FROM tomcat:${TOMCAT_VERSION}-${TOMCAT_JRE}
|
||||||
|
|
||||||
|
# Install XMLStarlet for server.xml alterations
|
||||||
|
RUN apt-get update -qq \
|
||||||
|
&& apt-get install -y xmlstarlet \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# This is where the build artifacts go in the runtime image
|
# This is where the build artifacts go in the runtime image
|
||||||
WORKDIR /opt/guacamole
|
WORKDIR /opt/guacamole
|
||||||
|
|
||||||
@@ -68,4 +73,3 @@ USER guacamole
|
|||||||
# Start Guacamole under Tomcat, listening on 0.0.0.0:8080
|
# Start Guacamole under Tomcat, listening on 0.0.0.0:8080
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
CMD ["/opt/guacamole/bin/start.sh" ]
|
CMD ["/opt/guacamole/bin/start.sh" ]
|
||||||
|
|
||||||
|
@@ -910,6 +910,58 @@ associate_json() {
|
|||||||
# Add required .jar files to GUACAMOLE_EXT
|
# Add required .jar files to GUACAMOLE_EXT
|
||||||
ln -s /opt/guacamole/json/guacamole-auth-*.jar "$GUACAMOLE_EXT"
|
ln -s /opt/guacamole/json/guacamole-auth-*.jar "$GUACAMOLE_EXT"
|
||||||
}
|
}
|
||||||
|
##
|
||||||
|
## Sets up Tomcat's remote IP valve that allows gathering the remote IP
|
||||||
|
## from headers set by a remote proxy
|
||||||
|
## Upstream documentation: https://tomcat.apache.org/tomcat-8.5-doc/api/org/apache/catalina/valves/RemoteIpValve.html
|
||||||
|
##
|
||||||
|
enable_remote_ip_valve() {
|
||||||
|
# Add <Valve> element
|
||||||
|
xmlstarlet edit --inplace \
|
||||||
|
--insert '/Server/Service/Engine/Host/*' --type elem -n Valve \
|
||||||
|
--insert '/Server/Service/Engine/Host/Valve[not(@className)]' --type attr -n className -v org.apache.catalina.valves.RemoteIpValve \
|
||||||
|
$CATALINA_BASE/conf/server.xml
|
||||||
|
|
||||||
|
# Allowed IPs
|
||||||
|
if [ -z "$PROXY_ALLOWED_IPS_REGEX" ]; then
|
||||||
|
echo "Using default Tomcat allowed IPs regex"
|
||||||
|
else
|
||||||
|
xmlstarlet edit --inplace \
|
||||||
|
--insert '/Server/Service/Engine/Host/Valve[@className="org.apache.catalina.valves.RemoteIpValve"]' \
|
||||||
|
--type attr -n internalProxies -v "$PROXY_ALLOWED_IPS_REGEX" \
|
||||||
|
$CATALINA_BASE/conf/server.xml
|
||||||
|
fi
|
||||||
|
|
||||||
|
# X-Forwarded-For
|
||||||
|
if [ -z "$PROXY_IP_HEADER" ]; then
|
||||||
|
echo "Using default Tomcat proxy IP header"
|
||||||
|
else
|
||||||
|
xmlstarlet edit --inplace \
|
||||||
|
--insert "/Server/Service/Engine/Host/Valve[@className='org.apache.catalina.valves.RemoteIpValve']" \
|
||||||
|
--type attr -n remoteIpHeader -v "$PROXY_IP_HEADER" \
|
||||||
|
$CATALINA_BASE/conf/server.xml
|
||||||
|
fi
|
||||||
|
|
||||||
|
# X-Forwarded-Proto
|
||||||
|
if [ -z "$PROXY_PROTOCOL_HEADER" ]; then
|
||||||
|
echo "Using default Tomcat proxy protocol header"
|
||||||
|
else
|
||||||
|
xmlstarlet edit --inplace \
|
||||||
|
--insert "/Server/Service/Engine/Host/Valve[@className='org.apache.catalina.valves.RemoteIpValve']" \
|
||||||
|
--type attr -n protocolHeader -v "$PROXY_PROTOCOL_HEADER" \
|
||||||
|
$CATALINA_BASE/conf/server.xml
|
||||||
|
fi
|
||||||
|
|
||||||
|
# X-Forwarded-By
|
||||||
|
if [ -z "$PROXY_BY_HEADER" ]; then
|
||||||
|
echo "Using default Tomcat proxy forwarded by header"
|
||||||
|
else
|
||||||
|
xmlstarlet edit --inplace \
|
||||||
|
--insert "/Server/Service/Engine/Host/Valve[@className='org.apache.catalina.valves.RemoteIpValve']" \
|
||||||
|
--type attr -n remoteIpProxiesHeader -v "$PROXY_BY_HEADER" \
|
||||||
|
$CATALINA_BASE/conf/server.xml
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
##
|
##
|
||||||
## Adds api-session-timeout to guacamole.properties
|
## Adds api-session-timeout to guacamole.properties
|
||||||
@@ -932,6 +984,11 @@ start_guacamole() {
|
|||||||
done
|
done
|
||||||
cp -R /usr/local/tomcat/conf $CATALINA_BASE
|
cp -R /usr/local/tomcat/conf $CATALINA_BASE
|
||||||
|
|
||||||
|
# Set up Tomcat RemoteIPValve
|
||||||
|
if [ "$REMOTE_IP_VALVE_ENABLED" = "true" ]; then
|
||||||
|
enable_remote_ip_valve
|
||||||
|
fi
|
||||||
|
|
||||||
# Install webapp
|
# Install webapp
|
||||||
ln -sf /opt/guacamole/guacamole.war $CATALINA_BASE/webapps/${WEBAPP_CONTEXT:-guacamole}.war
|
ln -sf /opt/guacamole/guacamole.war $CATALINA_BASE/webapps/${WEBAPP_CONTEXT:-guacamole}.war
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user