-
Notifications
You must be signed in to change notification settings - Fork 0
Installation Guide
This guide provides detailed instructions for installing the nginx-torblocker module on various systems.
Before installing the module, ensure you have the following:
- Operating System: Linux (Ubuntu 18.04+, CentOS 7+, Debian 9+)
- Nginx: Version 1.18.0 or later (installed and running)
- Compiler: GCC or compatible C compiler
- Memory: At least 512MB available RAM
- Network: Internet access for downloading sources and Tor lists
sudo apt-get update
sudo apt-get install -y build-essential gcc wget curl
sudo apt-get install -y libpcre3-dev zlib1g-dev libssl-dev
sudo yum groupinstall "Development Tools"
sudo yum install -y pcre-devel zlib-devel openssl-devel wget curl
apk add --no-cache build-base gcc wget curl
apk add --no-cache pcre-dev zlib-dev openssl-dev
First, determine your exact Nginx version:
nginx -v
Example output:
nginx version: nginx/1.26.0
Important: The module must be built against the exact same version of Nginx you're running.
Download the source code matching your Nginx version:
# Create a temporary build directory
mkdir -p ~/nginx-build && cd ~/nginx-build
# Download the matching Nginx source (replace 1.26.0 with your version)
NGINX_VERSION=$(nginx -v 2>&1 | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
# Extract the source
tar xzf nginx-${NGINX_VERSION}.tar.gz
# Clone the nginx-torblocker repository
git clone https://github.com/RumenDamyanov/nginx-torblocker.git
cd nginx-torblocker
# Enter the Nginx source directory
cd ~/nginx-build/nginx-${NGINX_VERSION}
# Configure Nginx with the module
./configure --add-dynamic-module=../nginx-torblocker/src
# Build only the modules (not the entire Nginx)
make modules
Expected output:
make -f objs/Makefile modules
make[1]: Entering directory '/home/user/nginx-build/nginx-1.26.0'
cc -c -fPIC -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter...
cc -o objs/ngx_http_torblocker_module.so ...
make[1]: Leaving directory '/home/user/nginx-build/nginx-1.26.0'
# Copy to the standard Nginx modules directory
sudo cp objs/ngx_http_torblocker_module.so /usr/lib/nginx/modules/
# Set proper permissions
sudo chmod 644 /usr/lib/nginx/modules/ngx_http_torblocker_module.so
# Create custom modules directory
sudo mkdir -p /etc/nginx/modules
# Copy module
sudo cp objs/ngx_http_torblocker_module.so /etc/nginx/modules/
# Set permissions
sudo chmod 644 /etc/nginx/modules/ngx_http_torblocker_module.so
Edit your main Nginx configuration file:
sudo nano /etc/nginx/nginx.conf
Add the following line at the very top of the file (before any other directives):
load_module modules/ngx_http_torblocker_module.so;
load_module /etc/nginx/modules/ngx_http_torblocker_module.so;
Complete example nginx.conf:
load_module modules/ngx_http_torblocker_module.so;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Enable Tor blocking globally
torblock on;
server {
listen 80;
server_name example.com;
location / {
root /var/www/html;
index index.html;
}
}
}
Test the Nginx configuration syntax:
sudo nginx -t
Expected output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
sudo systemctl restart nginx
# Or if using init.d
sudo service nginx restart
Check that Nginx is running and the module is loaded:
# Check Nginx status
sudo systemctl status nginx
# Check for module-related log entries
sudo tail -f /var/log/nginx/error.log
# Test that the module is working
curl -I http://localhost
sudo nginx -V 2>&1 | grep -o "configure arguments.*" | tr ' ' '\n' | grep module
# Check if Tor blocking is active (should see no errors)
echo "torblock on;" | sudo nginx -t -c /dev/stdin
# Watch for any module-related messages
sudo tail -f /var/log/nginx/error.log | grep -i tor
- Default Nginx modules directory:
/usr/lib/nginx/modules/
- Service management:
systemctl
- Configuration file:
/etc/nginx/nginx.conf
- Default Nginx modules directory:
/usr/lib64/nginx/modules/
- Service management:
systemctl
(CentOS 7+) orservice
(CentOS 6) - Configuration file:
/etc/nginx/nginx.conf
For Docker deployments, see the Docker Installation Guide.
nginx: [emerg] dlopen() "/usr/lib/nginx/modules/ngx_http_torblocker_module.so" failed
Solutions:
- Verify the file exists:
ls -la /usr/lib/nginx/modules/ngx_http_torblocker_module.so
- Check permissions:
sudo chmod 644 /usr/lib/nginx/modules/ngx_http_torblocker_module.so
- Ensure correct path in
load_module
directive
nginx: [emerg] module version 1024000 instead of 1026000
Solutions:
- Rebuild the module against the correct Nginx version
- Verify versions match:
nginx -v
vs build source version
nginx: [emerg] dlopen() failed (13: Permission denied)
Solutions:
- Check SELinux:
sudo setsebool -P httpd_execmem 1
- Fix file permissions:
sudo chmod 644 /path/to/module.so
- Check directory permissions:
sudo chmod 755 /usr/lib/nginx/modules/
After successful installation:
- Basic Configuration: See Basic Configuration Guide
- Testing: Review Testing Procedures
- Real-World Examples: Explore Usage Examples
Remove temporary build files:
cd ~
rm -rf ~/nginx-build
The module is now installed and ready for configuration!