Fix bug 70360 - Add NGINX_ACCESS_LOG to enable nginx access logs (#49)

Co-authored-by: Vladimir Ischenko <vladimir.ischenko@onlyoffice.com>
Co-committed-by: Vladimir Ischenko <vladimir.ischenko@onlyoffice.com>
This commit is contained in:
Vladimir Ischenko 2025-10-07 12:00:52 +00:00 committed by Alexey Golubev
parent 5da9390fe6
commit a26d08992a
2 changed files with 9 additions and 1 deletions

View file

@ -203,6 +203,7 @@ Below is the complete list of parameters that can be set using environment varia
- **REDIS_SERVER_DB**: The Redis database index number to select. Defaults to `0`.
- **NGINX_WORKER_PROCESSES**: Defines the number of nginx worker processes.
- **NGINX_WORKER_CONNECTIONS**: Sets the maximum number of simultaneous connections that can be opened by a nginx worker process.
- **NGINX_ACCESS_LOG**: Defines whether access logging is enabled. Defaults to `false`.
- **SECURE_LINK_SECRET**: Defines secret for the nginx config directive [secure_link_md5](https://nginx.org/en/docs/http/ngx_http_secure_link_module.html#secure_link_md5). Defaults to `random string`.
- **JWT_ENABLED**: Specifies the enabling the JSON Web Token validation by the ONLYOFFICE Document Server. Defaults to `true`.
- **JWT_SECRET**: Defines the secret key to validate the JSON Web Token in the request to the ONLYOFFICE Document Server. Defaults to random value.

View file

@ -103,6 +103,7 @@ NGINX_ONLYOFFICE_EXAMPLE_CONF="${NGINX_ONLYOFFICE_EXAMPLE_PATH}/includes/ds-exam
NGINX_CONFIG_PATH="/etc/nginx/nginx.conf"
NGINX_WORKER_PROCESSES=${NGINX_WORKER_PROCESSES:-1}
NGINX_ACCESS_LOG=${NGINX_ACCESS_LOG:-false}
# Limiting the maximum number of simultaneous connections due to possible memory shortage
LIMIT=$(ulimit -n); [ $LIMIT -gt 1048576 ] && LIMIT=1048576
NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-$LIMIT}
@ -604,7 +605,13 @@ update_nginx_settings(){
# Set up nginx
sed 's/^worker_processes.*/'"worker_processes ${NGINX_WORKER_PROCESSES};"'/' -i ${NGINX_CONFIG_PATH}
sed 's/worker_connections.*/'"worker_connections ${NGINX_WORKER_CONNECTIONS};"'/' -i ${NGINX_CONFIG_PATH}
sed 's/access_log.*/'"access_log off;"'/' -i ${NGINX_CONFIG_PATH}
if [ "${NGINX_ACCESS_LOG}" = "true" ]; then
touch "${DS_LOG_DIR}/nginx.access.log"
sed -ri 's|^\s*access_log\b.*;|access_log '"${DS_LOG_DIR}"'/nginx.access.log;|' "${NGINX_CONFIG_PATH}" "${NGINX_ONLYOFFICE_PATH}/includes/ds-common.conf" 2>/dev/null
else
sed -ri 's|^\s*access_log\b.*;|access_log off;|' "${NGINX_CONFIG_PATH}"
fi
# setup HTTPS
if [ -f "${SSL_CERTIFICATE_PATH}" -a -f "${SSL_KEY_PATH}" ]; then