Skip to content

Commit

Permalink
Toggle secure websockets on and off for RCON web interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Dids committed Feb 9, 2022
1 parent 83f0686 commit 6d1dc42
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ ENV RUST_UPDATE_BRANCH "public"
ENV RUST_START_MODE "0"
ENV RUST_OXIDE_ENABLED "0"
ENV RUST_OXIDE_UPDATE_ON_BOOT "1"
ENV RUST_RCON_SECURE_WEBSOCKET "0"
ENV RUST_SERVER_WORLDSIZE "3500"
ENV RUST_SERVER_MAXPLAYERS "500"
ENV RUST_SERVER_SAVE_INTERVAL "600"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ RUST_UPDATE_BRANCH (DEFAULT: "public" - Set to match the branch that you want to
RUST_START_MODE (DEFAULT: "0" - Determines if the server should update and then start (0), only update (1) or only start (2))
RUST_OXIDE_ENABLED (DEFAULT: "0" - Set to 1 to automatically install the latest version of Oxide)
RUST_OXIDE_UPDATE_ON_BOOT (DEFAULT: "1" - Set to 0 to disable automatic update of Oxide on boot)
RUST_RCON_SECURE_WEBSOCKET (DEFAULT: "0" - Set to 1 to enable secure websocket connections to the RCON web interface)
```

# Logging and rotating logs
Expand Down
16 changes: 15 additions & 1 deletion fix_conn.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash

# Enable debugging
# set -x

# $scope.Address = $scope.Address.trim();

Expand All @@ -19,3 +22,14 @@ sed -i -e 's/'"$OLD_HELP_TEXT"'/'"$NEW_HELP_TEXT"'/g' /usr/share/nginx/html/html
if grep -q "ng-model=\"Address\"" /usr/share/nginx/html/html/connect.html; then
sed -i -e '14,19d' /usr/share/nginx/html/html/connect.html
fi

# Enable or disable secure websockets
if [ "$RUST_RCON_SECURE_WEBSOCKET" = "1" ]; then
# Change "ws://" to "wss://" in /usr/share/nginx/html/js/rconService.js
echo "Enabling secure websockets!"
sed -i -e 's/ws:\/\//wss:\/\//g' /usr/share/nginx/html/js/rconService.js
else
# Change "wss://" to "ws://" in /usr/share/nginx/html/js/rconService.js
echo "Disabling secure websockets!"
sed -i -e 's/wss:\/\//ws:\/\//g' /usr/share/nginx/html/js/rconService.js
fi
4 changes: 2 additions & 2 deletions start_rust.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# Enable debugging
#set -x
# set -x

# Print the user we're currently running as
echo "Running as user: $(whoami)"
Expand Down Expand Up @@ -138,7 +138,7 @@ if [ ! -z ${RUST_RCON_WEB+x} ]; then
RUST_STARTUP_COMMAND="$RUST_STARTUP_COMMAND +rcon.web $RUST_RCON_WEB"
if [ "$RUST_RCON_WEB" = "1" ]; then
# Fix the webrcon (customizes a few elements)
bash /tmp/fix_conn.sh
bash -c "RUST_RCON_SECURE_WEBSOCKET=${RUST_RCON_SECURE_WEBSOCKET} /tmp/fix_conn.sh"

# Start nginx (in the background)
echo "Starting web server.."
Expand Down

0 comments on commit 6d1dc42

Please sign in to comment.