diff --git a/docker/containers/tactical-nginx/entrypoint.sh b/docker/containers/tactical-nginx/entrypoint.sh index f50b5c5a..3d301065 100644 --- a/docker/containers/tactical-nginx/entrypoint.sh +++ b/docker/containers/tactical-nginx/entrypoint.sh @@ -31,9 +31,12 @@ else fi fi +nginxdefaultconf='/etc/nginx/nginx.conf' # increase default nginx worker connections -/bin/bash -c "sed -i 's/worker_connections.*/worker_connections ${WORKER_CONNECTIONS};/g' /etc/nginx/nginx.conf" +/bin/bash -c "sed -i 's/worker_connections.*/worker_connections ${WORKER_CONNECTIONS};/g' $nginxdefaultconf" +sudo sed -i '1s/^/worker_rlimit_nofile 1000000;\ +/' $nginxdefaultconf if [[ $DEV -eq 1 ]]; then API_NGINX=" diff --git a/install.sh b/install.sh index 9a30c0dc..82e8777f 100644 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -SCRIPT_VERSION="64" +SCRIPT_VERSION="65" SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/install.sh' sudo apt install -y curl wget dirmngr gnupg lsb-release @@ -174,8 +174,12 @@ print_green 'Installing Nginx' sudo apt install -y nginx sudo systemctl stop nginx -sudo sed -i 's/worker_connections.*/worker_connections 2048;/g' /etc/nginx/nginx.conf -sudo sed -i 's/# server_names_hash_bucket_size.*/server_names_hash_bucket_size 64;/g' /etc/nginx/nginx.conf +nginxdefaultconf='/etc/nginx/nginx.conf' +sudo sed -i '/worker_rlimit_nofile.*/d' $nginxdefaultconf +sudo sed -i 's/worker_connections.*/worker_connections 2048;/g' $nginxdefaultconf +sudo sed -i 's/# server_names_hash_bucket_size.*/server_names_hash_bucket_size 64;/g' $nginxdefaultconf +sudo sed -i '1s/^/worker_rlimit_nofile 1000000;\ +/' $nginxdefaultconf print_green 'Installing NodeJS' diff --git a/restore.sh b/restore.sh index 8e44b5df..92b87470 100755 --- a/restore.sh +++ b/restore.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -SCRIPT_VERSION="38" +SCRIPT_VERSION="39" SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/restore.sh' sudo apt update @@ -126,7 +126,15 @@ sudo systemctl stop nginx sudo rm -rf /etc/nginx sudo mkdir /etc/nginx sudo tar -xzf $tmp_dir/nginx/etc-nginx.tar.gz -C /etc/nginx -sudo sed -i 's/worker_connections.*/worker_connections 2048;/g' /etc/nginx/nginx.conf +nginxdefaultconf='/etc/nginx/nginx.conf' +sudo sed -i 's/worker_connections.*/worker_connections 2048;/g' $nginxdefaultconf +CHECK_NGINX_NOLIMIT=$(grep "worker_rlimit_nofile 1000000" $nginxdefaultconf) +if ! [[ $CHECK_NGINX_NOLIMIT ]]; then +sudo sed -i '/worker_rlimit_nofile.*/d' $nginxdefaultconf +printf >&2 "${GREEN}Increasing nginx open file limit${NC}\n" +sudo sed -i '1s/^/worker_rlimit_nofile 1000000;\ +/' $nginxdefaultconf +fi rmmdomain=$(grep server_name /etc/nginx/sites-available/rmm.conf | grep -v 301 | head -1 | tr -d " \t" | sed 's/.*server_name//' | tr -d ';') frontenddomain=$(grep server_name /etc/nginx/sites-available/frontend.conf | grep -v 301 | head -1 | tr -d " \t" | sed 's/.*server_name//' | tr -d ';') meshdomain=$(grep server_name /etc/nginx/sites-available/meshcentral.conf | grep -v 301 | head -1 | tr -d " \t" | sed 's/.*server_name//' | tr -d ';') diff --git a/update.sh b/update.sh index 8a8c6e63..105813a1 100644 --- a/update.sh +++ b/update.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -SCRIPT_VERSION="136" +SCRIPT_VERSION="137" SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/update.sh' LATEST_SETTINGS_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/api/tacticalrmm/tacticalrmm/settings.py' YELLOW='\033[1;33m' @@ -165,13 +165,22 @@ EOF )" echo "${uwsgini}" > /rmm/api/tacticalrmm/app.ini -CHECK_NGINX_WORKER_CONN=$(grep "worker_connections 2048" /etc/nginx/nginx.conf) +nginxdefaultconf='/etc/nginx/nginx.conf' +CHECK_NGINX_WORKER_CONN=$(grep "worker_connections 2048" $nginxdefaultconf) if ! [[ $CHECK_NGINX_WORKER_CONN ]]; then printf >&2 "${GREEN}Changing nginx worker connections to 2048${NC}\n" - sudo sed -i 's/worker_connections.*/worker_connections 2048;/g' /etc/nginx/nginx.conf + sudo sed -i 's/worker_connections.*/worker_connections 2048;/g' $nginxdefaultconf fi -sudo sed -i 's/# server_names_hash_bucket_size.*/server_names_hash_bucket_size 64;/g' /etc/nginx/nginx.conf +CHECK_NGINX_NOLIMIT=$(grep "worker_rlimit_nofile 1000000" $nginxdefaultconf) +if ! [[ $CHECK_NGINX_NOLIMIT ]]; then +sudo sed -i '/worker_rlimit_nofile.*/d' $nginxdefaultconf +printf >&2 "${GREEN}Increasing nginx open file limit${NC}\n" +sudo sed -i '1s/^/worker_rlimit_nofile 1000000;\ +/' $nginxdefaultconf +fi + +sudo sed -i 's/# server_names_hash_bucket_size.*/server_names_hash_bucket_size 64;/g' $nginxdefaultconf HAS_PY310=$(python3.10 --version | grep ${PYTHON_VER}) if ! [[ $HAS_PY310 ]]; then