Skip to content

Commit

Permalink
build(Nginx): Update to 1.26.2 (#1917)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreykwan authored Aug 23, 2024
1 parent e7ba216 commit c1fcca2
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions scripts/beforeInstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,26 @@ sudo -u ubuntu -g ubuntu mkdir $WISE_BUILD_FILES
sudo -u ubuntu -g ubuntu aws s3 sync --exclude "legacy.war" s3://wise-build-files $WISE_BUILD_FILES
chmod u+x $WISE_BUILD_FILES/sync.sh

echo "Installing Nginx"
apt-get install nginx -y
echo "Update apt repository to be able to use latest stable Nginx packages"
apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring -y
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor | tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" | tee /etc/apt/sources.list.d/nginx.list
apt update

echo "Adding ip to nginx.conf"
sed 's/http {/http {\n add_header ip $server_addr;/' -i /etc/nginx/nginx.conf
sed 's/include \/etc\/nginx\/sites-enabled\/\*;/include \/etc\/nginx\/sites-enabled\/\*;\n\n ##\n # Browser preferred language detection \(does NOT require AcceptLanguageModule\)\n ##\n\n map \$http_accept_language \$accept_language {\n ~\*\^tr tr;\n ~\*\^es es;\n ~\*\^pt pt;\n ~\*\^ja ja;\n ~\*\^zh-Hans zh-Hans;\n ~\*\^zh-Hant zh-Hant;\n ~\*\^zh-CN zh-Hans;\n ~\*\^zh-TW zh-Hant;\n }/' -i /etc/nginx/nginx.conf
echo "Installing Nginx 1.26.2"
apt-get install nginx=1.26.2-1~$(lsb_release -sc) -y

echo "Adding gzip_types to nginx.conf"
sed 's/gzip on;/gzip on;\n gzip_types text\/plain text\/xml image\/gif image\/jpeg image\/png image\/svg+xml application\/json application\/javascript application\/x-javascript text\/javascript text\/css;/' -i /etc/nginx/nginx.conf
sed 's/#gzip on;/gzip on;\n gzip_types text\/plain text\/xml image\/gif image\/jpeg image\/png image\/svg+xml application\/json application\/javascript application\/x-javascript text\/javascript text\/css;/' -i /etc/nginx/nginx.conf

echo "Remove TLS 1.0 from nginx.conf"
sed 's/TLSv1 //g' -i /etc/nginx/nginx.conf
echo "Adding language detection to nginx.conf"
sed 's/include \/etc\/nginx\/conf.d\/\*.conf;/include \/etc\/nginx\/conf.d\/\*.conf;\n\n ##\n # Browser preferred language detection \(does NOT require AcceptLanguageModule\)\n ##\n\n map \$http_accept_language \$accept_language {\n ~\*\^tr tr;\n ~\*\^es es;\n ~\*\^pt pt;\n ~\*\^ja ja;\n ~\*\^zh-Hans zh-Hans;\n ~\*\^zh-Hant zh-Hant;\n ~\*\^zh-CN zh-Hans;\n ~\*\^zh-TW zh-Hant;\n }/' -i /etc/nginx/nginx.conf

echo "Remove TLS 1.1 from nginx.conf"
sed 's/TLSv1.1 //g' -i /etc/nginx/nginx.conf
echo "Clearing out /etc/nginx/conf.d folder"
rm -f /etc/nginx/conf.d/*

echo "Copying WISE Nginx config file to Nginx sites-enabled folder"
rm -f /etc/nginx/sites-enabled/*
cp $WISE_BUILD_FILES/client/$ENV/wise.conf /etc/nginx/sites-enabled/wise.conf
echo "Copying WISE Nginx config file to Nginx conf.d folder"
cp $WISE_BUILD_FILES/client/$ENV/wise.conf /etc/nginx/conf.d/wise.conf

echo "Restarting Nginx"
systemctl restart nginx
Expand Down

0 comments on commit c1fcca2

Please sign in to comment.