mirror of
https://github.com/qemus/qemu-docker.git
synced 2025-12-24 13:38:05 +08:00
feat: Make webserver port configurable (#849)
This commit is contained in:
@@ -55,7 +55,7 @@ COPY --chmod=755 ./src /run/
|
||||
COPY --chmod=755 ./web /var/www/
|
||||
COPY --chmod=664 ./web/conf/defaults.json /usr/share/novnc
|
||||
COPY --chmod=664 ./web/conf/mandatory.json /usr/share/novnc
|
||||
COPY --chmod=744 ./web/conf/nginx.conf /etc/nginx/sites-enabled/web.conf
|
||||
COPY --chmod=744 ./web/conf/nginx.conf /etc/nginx/default.conf
|
||||
|
||||
VOLUME /storage
|
||||
EXPOSE 22 5900 8006
|
||||
|
||||
@@ -45,7 +45,7 @@ if [[ "${DISPLAY,,}" == "web" ]]; then
|
||||
rm -f "$PAGE"
|
||||
else
|
||||
if [[ "${DISPLAY,,}" == "vnc" ]]; then
|
||||
html "You can now connect to VNC on port 5900." "0"
|
||||
html "You can now connect to VNC on port $VNC_PORT." "0"
|
||||
else
|
||||
html "The virtual machine was booted successfully." "0"
|
||||
fi
|
||||
|
||||
@@ -15,7 +15,7 @@ case "${DISPLAY,,}" in
|
||||
DISPLAY_OPTS="-display vnc=:0 -vga $VGA"
|
||||
;;
|
||||
"web" )
|
||||
DISPLAY_OPTS="-display vnc=:0,websocket=5700 -vga $VGA"
|
||||
DISPLAY_OPTS="-display vnc=:0,websocket=$WSS_PORT -vga $VGA"
|
||||
;;
|
||||
"disabled" )
|
||||
DISPLAY_OPTS="-display none -vga $VGA"
|
||||
@@ -43,7 +43,7 @@ DISPLAY_OPTS="-display egl-headless,rendernode=$RENDERNODE"
|
||||
DISPLAY_OPTS+=" -device $VGA"
|
||||
|
||||
[[ "${DISPLAY,,}" == "vnc" ]] && DISPLAY_OPTS+=" -vnc :0"
|
||||
[[ "${DISPLAY,,}" == "web" ]] && DISPLAY_OPTS+=" -vnc :0,websocket=5700"
|
||||
[[ "${DISPLAY,,}" == "web" ]] && DISPLAY_OPTS+=" -vnc :0,websocket=$WSS_PORT"
|
||||
|
||||
[ ! -d /dev/dri ] && mkdir -m 755 /dev/dri
|
||||
|
||||
|
||||
@@ -173,14 +173,14 @@ getUserPorts() {
|
||||
|
||||
getHostPorts() {
|
||||
|
||||
local list=$1
|
||||
local vnc="5900"
|
||||
local web="8006"
|
||||
local list="$1"
|
||||
|
||||
[ -z "$list" ] && list="$web" || list+=",$web"
|
||||
if [[ "${WEB:-}" != [Nn]* ]]; then
|
||||
[ -z "$list" ] && list="$WEB_PORT" || list+=",$WEB_PORT"
|
||||
fi
|
||||
|
||||
if [[ "${DISPLAY,,}" == "vnc" || "${DISPLAY,,}" == "web" ]]; then
|
||||
[ -z "$list" ] && list="$vnc" || list+=",$vnc"
|
||||
[ -z "$list" ] && list="$VNC_PORT" || list+=",$VNC_PORT"
|
||||
fi
|
||||
|
||||
[ -z "$list" ] && echo "" && return 0
|
||||
|
||||
41
src/reset.sh
41
src/reset.sh
@@ -11,7 +11,7 @@ echo "❯ For support visit $SUPPORT"
|
||||
|
||||
# Docker environment variables
|
||||
|
||||
: "${BOOT:=""}" # URL of the ISO file
|
||||
: "${BOOT:=""}" # Path of ISO file
|
||||
: "${DEBUG:="N"}" # Disable debugging
|
||||
: "${MACHINE:="q35"}" # Machine selection
|
||||
: "${ALLOCATE:=""}" # Preallocate diskspace
|
||||
@@ -157,38 +157,39 @@ addPackage() {
|
||||
return 0
|
||||
}
|
||||
|
||||
: "${VNC_PORT:="5900"}" # VNC port
|
||||
: "${WEB_PORT:="8006"}" # Webserver port
|
||||
: "${WSS_PORT:="5700"}" # Websockets port
|
||||
|
||||
cp -r /var/www/* /run/shm
|
||||
html "Starting $APP for Docker..."
|
||||
|
||||
if [[ "${WEB:-}" != [Nn]* ]]; then
|
||||
|
||||
cp /etc/nginx/default.conf /etc/nginx/sites-enabled/web.conf
|
||||
|
||||
user="admin"
|
||||
[ -n "${USER:-}" ] && user="${USER:-}"
|
||||
|
||||
|
||||
if [ -n "${PASS:-}" ]; then
|
||||
|
||||
|
||||
# Set password
|
||||
echo "$user:{PLAIN}${PASS:-}" > /etc/nginx/.htpasswd
|
||||
|
||||
sed -i "s/auth_basic off/auth_basic \"NoVNC\"/g" /etc/nginx/sites-enabled/web.conf
|
||||
|
||||
else
|
||||
|
||||
sed -i "s/auth_basic \"NoVNC\"/auth_basic off/g" /etc/nginx/sites-enabled/web.conf
|
||||
|
||||
|
||||
fi
|
||||
|
||||
# Set password
|
||||
echo "$user:{PLAIN}${PASS:-}" > /etc/nginx/.htpasswd
|
||||
|
||||
|
||||
sed -i "s/listen 8006 default_server;/listen $WEB_PORT default_server;/g" /etc/nginx/sites-enabled/web.conf
|
||||
sed -i "s/proxy_pass http://127.0.0.1:5700/;/proxy_pass http://127.0.0.1:$WSS_PORT/;/g" /etc/nginx/sites-enabled/web.conf
|
||||
|
||||
# shellcheck disable=SC2143
|
||||
if [ -f /proc/net/if_inet6 ] && [ -n "$(ifconfig -a | grep inet6)" ]; then
|
||||
|
||||
sed -i "s/listen 8006 default_server;/listen [::]:8006 default_server ipv6only=off;/g" /etc/nginx/sites-enabled/web.conf
|
||||
|
||||
else
|
||||
|
||||
sed -i "s/listen [::]:8006 default_server ipv6only=off;/listen 8006 default_server;/g" /etc/nginx/sites-enabled/web.conf
|
||||
|
||||
|
||||
sed -i "s/listen $WEB_PORT default_server;/listen [::]:$WEB_PORT default_server ipv6only=off;/g" /etc/nginx/sites-enabled/web.conf
|
||||
|
||||
fi
|
||||
|
||||
|
||||
# Start webserver
|
||||
nginx -e stderr
|
||||
|
||||
|
||||
Reference in New Issue
Block a user