Skip to content

Commit 5bb5f9a

Browse files
Merge pull request #33 from StrangeRanger/dev
Refactor package management and update documentation
2 parents 1ecc804 + 7f6959e commit 5bb5f9a

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

hardening/Nginx WAF/nginx-waf.bash

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ fi
110110
[[ $C_NGINX_CONFIG_ARGS == *--with-http_xslt_module* ]] && require_pkg "libxslt1-dev"
111111
[[ $C_NGINX_CONFIG_ARGS == *ssl* ]] && require_pkg "libssl-dev"
112112

113+
114+
####[ Main ]################################################################################
115+
116+
117+
read -rp "${C_NOTE}We will now install and configure ModSecurity. Press [Enter] to continue."
118+
119+
###
120+
### [ Install Required Packages ]
121+
###
122+
113123
for pkg in "${required_pkgs[@]}"; do
114124
if ! dpkg -s "$pkg" &>/dev/null; then
115125
missing_pkgs+=("$pkg")
@@ -118,16 +128,10 @@ done
118128

119129
if (( ${#missing_pkgs[@]} > 0 )); then
120130
echo "${C_INFO}Installing missing packages: ${missing_pkgs[*]}"
121-
sudo apt get update
122-
sudo apt get install -y "${missing_pkgs[@]}"
131+
sudo apt-get update
132+
sudo apt-get install -y "${missing_pkgs[@]}"
123133
fi
124134

125-
126-
####[ Main ]################################################################################
127-
128-
129-
read -rp "${C_NOTE}We will now install and configure ModSecurity. Press [Enter] to continue."
130-
131135
###
132136
### [ Clone and build ModSecurity ]
133137
###
@@ -271,7 +275,9 @@ sudo systemctl restart nginx
271275
echo "${C_SUCC}Finished installing and configuring ModSecurity WAF for Nginx"
272276
cat <<EOF
273277
${C_NOTE}To enable ModSecurity WAF for a site, add these lines to its Nginx server block, for example in '/etc/nginx/sites-enabled/':
274-
${C_CYAN}## Modsecurity settings
275-
modsecurity on;
276-
modsecurity_rules_file /etc/nginx/modsec/main.conf;${C_NC}
278+
${C_CYAN}
279+
## Modsecurity settings
280+
modsecurity on;
281+
modsecurity_rules_file /etc/nginx/modsec/main.conf;
282+
${C_NC}
277283
EOF

0 commit comments

Comments
 (0)