Skip to content

Commit 1ecc804

Browse files
Merge pull request #32 from StrangeRanger/dev
Update documentation and refine configuration prompts
2 parents 5ac50aa + 2e96426 commit 1ecc804

5 files changed

Lines changed: 49 additions & 41 deletions

File tree

hardening/Nginx WAF/CHANGELOG.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,36 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
7+
## v1.0.0-beta.3 - 2026-05-20
88

9-
## [1.0.0-beta] - 2026-05-17
9+
### Added
10+
11+
- Added prompt before executing the script.
12+
- Added manual instructions to enable ModSecurity WAF for a site.
13+
14+
### Fixed
15+
16+
- Added missing `sudo` where needed.
17+
18+
### Removed
19+
20+
- Removed EUID check.
21+
22+
## v1.0.0-beta.2 - 2026-05-17
1023

1124
### Added
1225

13-
- Added Nginx WAF hardening tool for installing and configuring ModSecurity with Nginx.
1426
- Added automatic installation of required build dependencies for ModSecurity and Nginx dynamic module compilation.
27+
28+
## v1.0.0-beta - 2026-05-16
29+
30+
Initial beta release of the Nginx WAF hardening script.
31+
32+
### Added
33+
34+
- Added Nginx WAF hardening tool for installing and configuring ModSecurity with Nginx.
1535
- Added ModSecurity v3 source build and installation workflow.
1636
- Added ModSecurity-nginx dynamic module build using the installed Nginx version and configure arguments.
1737
- Added Nginx module loading configuration through `modules-available` and `modules-enabled`.
1838
- Added OWASP Core Rule Set installation and ModSecurity main configuration generation.
1939
- Added Nginx configuration validation and restart after setup.
20-
21-
### Fixed
22-
23-
- Added missing build dependencies required by Nginx SSL, XSLT, image filter, Perl, gzip, and ModSecurity modules.
24-
- Removed redundant or unused dependency entries from the required package list.
25-
- Limited Nginx module-specific build dependencies to systems whose installed Nginx was built with those modules.

hardening/Nginx WAF/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,16 @@ It may install additional development packages depending on how the installed Ng
3333

3434
## Usage
3535

36-
Run the script from its directory:
36+
From the repository root:
3737

3838
```bash
39-
cd hardening/Nginx\ WAF/
40-
sudo ./nginx-waf.bash
39+
./hardening/Nginx\ WAF/nginx-waf.bash
40+
```
41+
42+
OR from the script directory:
43+
44+
```bash
45+
./nginx-waf.bash
4146
```
4247

4348
## Execution Summary

hardening/Nginx WAF/nginx-waf.bash

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Nginx to load the module, and sets up the OWASP Core Rule Set for basic protection against
77
# common web vulnerabilities.
88
#
9-
# Version: v1.0.0-beta
9+
# Version: v1.0.0-beta.3
1010
# License: MIT License
1111
# Copyright (c) 2026 Hunter T. (StrangeRanger)
1212
#
@@ -61,17 +61,10 @@ missing_pkgs=()
6161
####[Functions]#############################################################################
6262

6363

64-
error_exit() {
65-
local message="${1:-An unknown error occurred}"
66-
local exit_code="${2:-1}"
67-
68-
echo "${C_ERROR}${message}" >&2
69-
exit "$exit_code"
70-
}
71-
7264
on_err() {
7365
local exit_code=$?
74-
error_exit "Command failed at line ${BASH_LINENO[0]}: ${BASH_COMMAND}" "$exit_code"
66+
echo "${C_ERROR}Command failed at line ${BASH_LINENO[0]}: ${BASH_COMMAND}"
67+
echo "${C_ERROR}Exit code: $exit_code"
7568
}
7669

7770
require_non_empty() {
@@ -101,10 +94,6 @@ trap on_err ERR
10194
####[ Initial Checks ]######################################################################
10295

10396

104-
if (( EUID != 0 )); then
105-
error_exit "This script must be run with root privileges"
106-
fi
107-
10897
if command -v nginx &>/dev/null; then
10998
C_NGINX_VERSION="$(nginx -V 2>&1 | sed -n 's/^nginx version: nginx\/\([0-9.]\+\).*/\1/p')"
11099
C_NGINX_CONFIG_ARGS="$(nginx -V 2>&1 | awk -F': ' '/configure arguments/ {print $2}')"
@@ -129,15 +118,15 @@ done
129118

130119
if (( ${#missing_pkgs[@]} > 0 )); then
131120
echo "${C_INFO}Installing missing packages: ${missing_pkgs[*]}"
132-
apt-get update
133-
apt-get install -y "${missing_pkgs[@]}"
121+
sudo apt get update
122+
sudo apt get install -y "${missing_pkgs[@]}"
134123
fi
135124

136125

137126
####[ Main ]################################################################################
138127

139128

140-
echo "${C_INFO}Starting ModSecurity installation and configuration process..."
129+
read -rp "${C_NOTE}We will now install and configure ModSecurity. Press [Enter] to continue."
141130

142131
###
143132
### [ Clone and build ModSecurity ]
@@ -173,7 +162,7 @@ echo "${C_INFO}Compiling ModSecurity..."
173162
make -j"$(nproc --ignore=1)"
174163

175164
echo "${C_INFO}Installing ModSecurity..."
176-
make install
165+
sudo make install
177166
popd >/dev/null
178167

179168
###
@@ -209,7 +198,7 @@ echo "${C_INFO}Compiling ModSecurity Nginx module..."
209198
make modules
210199

211200
echo "${C_INFO}Installing ModSecurity Nginx module..."
212-
mkdir -p "$C_MODULES_PATH"
201+
sudo mkdir -p "$C_MODULES_PATH"
213202
sudo cp objs/"$C_SO_FILE" "$C_MODULES_PATH"
214203
sudo chmod 0644 "$C_MODULES_PATH/$C_SO_FILE"
215204
popd >/dev/null
@@ -279,4 +268,10 @@ sudo nginx -t
279268
echo "${C_INFO}Restarting Nginx to apply changes..."
280269
sudo systemctl restart nginx
281270

282-
echo "${C_SUCC}DONE"
271+
echo "${C_SUCC}Finished installing and configuring ModSecurity WAF for Nginx"
272+
cat <<EOF
273+
${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}
277+
EOF

hardening/SSHD Hardening/README.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SSHD Hardening
22

3-
Hardens the OpenSSH server configuration using settings aligned with Lynis recommendations.
3+
Hardens the OpenSSH server configuration using settings aligned with [Lynis](https://github.com/CISOfy/lynis) recommendations.
44

55
> [!CAUTION]
66
> This script modifies the system SSH daemon configuration. Treat it as a high-risk change on remote systems because an invalid or overly restrictive SSH configuration can lock you out.
@@ -60,21 +60,13 @@ The script creates two backup types:
6060
- Permanent backup: `/etc/ssh/sshd_config.bak`
6161
- Session backup: temporary backup used for automatic restoration if the script is interrupted during configuration changes
6262

63-
If `/etc/ssh/sshd_config.bak` already exists, the script asks whether to overwrite it.
64-
6563
## Safety Notes
6664

6765
- Keep your current SSH session open while testing a new login.
6866
- Review whether agent forwarding, TCP forwarding, X11 forwarding, and session limits are compatible with your use case.
6967

7068
## Verify
7169

72-
Validate the SSH configuration before relying on it:
73-
74-
```bash
75-
sudo sshd -t
76-
```
77-
7870
Check the active SSH service status:
7971

8072
```bash

hardening/UFW Cloudflare/ufw-cloudflare.bash

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ fi
104104
####[ Main ]################################################################################
105105

106106

107+
read -rp "${C_NOTE}We will now configure Cloudflare UFW rules. Press [Enter] to continue."
108+
107109
###
108110
### [ Initial Setup ]
109111
###

0 commit comments

Comments
 (0)