mirror of
https://github.com/ONLYOFFICE/Docker-Docs.git
synced 2025-04-18 15:04:02 +03:00
Co-authored-by: VyacheslavSemin <vyacheslav.semin@onlyoffice.com> Co-committed-by: VyacheslavSemin <vyacheslav.semin@onlyoffice.com>
35 lines
1.7 KiB
Bash
Executable File
35 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
if ! [ -d /tmp/proxy_nginx ]; then
|
|
mkdir /tmp/proxy_nginx
|
|
fi
|
|
cp -r /etc/nginx/* /tmp/proxy_nginx/
|
|
sed 's|\(worker_connections\) [[:digit:]]*;|\1 '$NGINX_WORKER_CONNECTIONS';|g' -i /tmp/proxy_nginx/nginx.conf
|
|
sed "s/\(worker_processes\).*/\1 $NGINX_WORKER_PROCESSES;/" -i /tmp/proxy_nginx/nginx.conf
|
|
if [[ -n "$NGINX_LOG_FORMAT" ]]; then
|
|
sed "s/\(log_format main\).*/\1 '$NGINX_LOG_FORMAT';/" -i /tmp/proxy_nginx/nginx.conf
|
|
fi
|
|
if [ $NGINX_ACCESS_LOG != "off" ]; then
|
|
sed 's|#*\(\s*access_log\).*;|\1 /var/log/nginx/access.log '$NGINX_ACCESS_LOG';|g' -i /tmp/proxy_nginx/nginx.conf
|
|
fi
|
|
envsubst < /tmp/proxy_nginx/includes/http-upstream.conf > /tmp/http-upstream.conf
|
|
envsubst < /etc/nginx/includes/ds-common.conf | tee /tmp/proxy_nginx/includes/ds-common.conf > /dev/null
|
|
sed "s,\(set \+\$secure_link_secret\).*,\1 "${SECURE_LINK_SECRET:-verysecretstring}";," -i /tmp/proxy_nginx/conf.d/ds.conf
|
|
sed "s/\(client_max_body_size\).*/\1 $NGINX_CLIENT_MAX_BODY_SIZE;/" -i /tmp/proxy_nginx/includes/ds-common.conf
|
|
if [[ ! -f "/proc/net/if_inet6" ]]; then
|
|
sed '/listen\s\+\[::[0-9]*\].\+/d' -i /tmp/proxy_nginx/conf.d/ds.conf
|
|
fi
|
|
if [[ -n "$INFO_ALLOWED_IP" ]]; then
|
|
declare -a IP_ALL=($INFO_ALLOWED_IP)
|
|
for ip in "${IP_ALL[@]}"; do
|
|
sed -i '/(info)/a\ allow '$ip'\;' /tmp/proxy_nginx/includes/ds-docservice.conf
|
|
done
|
|
fi
|
|
if [[ -n "$INFO_ALLOWED_USER" ]]; then
|
|
htpasswd -c -b /tmp/auth "${INFO_ALLOWED_USER}" "${INFO_ALLOWED_PASSWORD:-password}"
|
|
sed -i '/(info)/a\ auth_basic \"Authentication Required\"\;' /tmp/proxy_nginx/includes/ds-docservice.conf
|
|
sed -i '/auth_basic/a\ auth_basic_user_file \/tmp\/auth\;' /tmp/proxy_nginx/includes/ds-docservice.conf
|
|
fi
|
|
exec nginx -c /tmp/proxy_nginx/nginx.conf -g 'daemon off;'
|