Skip to content

Commit

Permalink
Merge pull request 'Add redisDB' (#113) from feature/redisDB into dev…
Browse files Browse the repository at this point in the history
  • Loading branch information
sk81biz committed Dec 27, 2024
2 parents 50016a4 + e01f434 commit 4fa8c9b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions config/nginx/onlyoffice.conf
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ server {
local redis_host = "127.0.0.1"
local redis_port = 6379
local redis_pass = ""
local redis_db = 0

red:set_timeout(1000) -- 1 second

Expand All @@ -136,6 +137,14 @@ server {
end
end

if redis_db ~= 0 then
local res, err = red:select(redis_db)
if not res then
ngx.log(ngx.ERR, "failed to select redis db: ", err)
return
end
end

local csp, err = red:hget(key, "data")

if csp == ngx.null or not csp then
Expand Down
1 change: 1 addition & 0 deletions install/docker/.env
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
REDIS_PORT=6379
REDIS_USER_NAME=""
REDIS_PASSWORD=""
REDIS_DB="0"

# rabbitmq #
RABBIT_CONTAINER_NAME=${CONTAINER_PREFIX}rabbitmq
Expand Down
2 changes: 2 additions & 0 deletions install/docker/docker-entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
REDIS_USER_NAME = {"User": os.environ["REDIS_USER_NAME"]} if environ.get("REDIS_USER_NAME") else None
REDIS_PASSWORD = {"Password": os.environ["REDIS_PASSWORD"]} if environ.get("REDIS_PASSWORD") else None
REDIS_CONNECTION_HOST = REDIS_HOST if REDIS_HOST else REDIS_CONTAINER_NAME
REDIS_DB = os.environ["REDIS_DB"] if environ.get("REDIS_DB") else 0

RABBIT_CONTAINER_NAME = os.environ["RABBIT_CONTAINER_NAME"] if environ.get("RABBIT_CONTAINER_NAME") else "onlyoffice-rabbitmq"
RABBIT_PROTOCOL = os.environ["RABBIT_PROTOCOL"] if environ.get("RABBIT_PROTOCOL") else "amqp"
Expand Down Expand Up @@ -254,6 +255,7 @@ def writeJsonFile(jsonFile, jsonData, indent=4):
jsonData = openJsonFile(filePath)
updateJsonData(jsonData,"$.Redis.Hosts.[0].Host", REDIS_CONNECTION_HOST)
updateJsonData(jsonData,"$.Redis.Hosts.[0].Port", REDIS_PORT)
updateJsonData(jsonData,"$.Redis.Database", REDIS_DB)
jsonData["Redis"].update(REDIS_USER_NAME) if REDIS_USER_NAME is not None else None
jsonData["Redis"].update(REDIS_PASSWORD) if REDIS_PASSWORD is not None else None
writeJsonFile(filePath, jsonData)
Expand Down
2 changes: 2 additions & 0 deletions install/docker/docspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ x-service: &x-service-base
REDIS_PORT: ${REDIS_PORT}
REDIS_USER_NAME: ${REDIS_USER_NAME}
REDIS_PASSWORD: ${REDIS_PASSWORD}
REDIS_DB: ${REDIS_DB}
RABBIT_CONTAINER_NAME: ${RABBIT_CONTAINER_NAME}
RABBIT_PROTOCOL: ${RABBIT_PROTOCOL}
RABBIT_HOST: ${RABBIT_HOST}
Expand Down Expand Up @@ -233,6 +234,7 @@ services:
- REDIS_HOST=${REDIS_HOST}
- REDIS_PORT=${REDIS_PORT}
- REDIS_PASSWORD=${REDIS_PASSWORD}
- REDIS_DB=${REDIS_DB}
- SERVICE_PORT=${SERVICE_PORT}
- DASHBOARDS_CONTAINER_NAME=${DASHBOARDS_CONTAINER_NAME}
- DASHBOARDS_USERNAME=${DASHBOARDS_USERNAME}
Expand Down
2 changes: 2 additions & 0 deletions install/docker/prepare-nginx-router.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ WRONG_PORTAL_NAME_URL=${WRONG_PORTAL_NAME_URL:-""}
REDIS_HOST=${REDIS_HOST:-"${REDIS_CONTAINER_NAME}"}
REDIS_PORT=${REDIS_PORT:-"6379"}
REDIS_PASSWORD=${REDIS_PASSWORD:-""}
REDIS_DB=${REDIS_DB:-"0"}

envsubst '$MAP_HASH_BUCKET_SIZE,$COUNT_WORKER_CONNECTIONS' < /etc/nginx/nginx.conf.template > /usr/local/openresty/nginx/conf/nginx.conf
sed -i "s~\(redis_host =\).*~\1 \"$REDIS_HOST\"~" /etc/nginx/conf.d/onlyoffice.conf
sed -i "s~\(redis_port =\).*~\1 $REDIS_PORT~" /etc/nginx/conf.d/onlyoffice.conf
sed -i "s~\(redis_pass =\).*~\1 \"$REDIS_PASSWORD\"~" /etc/nginx/conf.d/onlyoffice.conf
sed -i "s~\(redis_db =\).*~\1 $REDIS_DB~" /etc/nginx/conf.d/onlyoffice.conf
sed -i "s~\(\"wrongPortalNameUrl\":\).*,~\1 \"${WRONG_PORTAL_NAME_URL}\",~g" /var/www/public/scripts/config.json
echo "${DASHBOARDS_USERNAME:-onlyoffice}:$(openssl passwd -6 -stdin <<< "${DASHBOARDS_PASSWORD:-onlyoffice}")" > /etc/nginx/.htpasswd_dashboards

0 comments on commit 4fa8c9b

Please sign in to comment.