Skip to content

Nginx Deny From IP

Nginx is a very unique Web Server, today I will show how to deny IP using Nginx, Please note you must have this module installed in your Nginx web server , If you don't have it installed - Simply download my…

Sohaib Khan1 min read
Nginx Deny From IP — editorial illustration

Nginx is a very unique Web Server, today I will show how to deny IP using Nginx, Please note you must have this module installed in your Nginx web server , If you don't have it installed - Simply download my pre-compile Nginx which comes with all the necessary modules known to NGINX.

PLAINTEXT1 line
ngx_http_access_module

Will create a file under our conf directory lets called that block.conf, My conf directory is located at /etc/nginx/conf.d/. We are going to assume YOUR IP Address i.e. 8.8.8.8 & 8.8.4.4

PLAINTEXT5 lines
nano /etc/nginx/conf.d/block.conf

deny 9.9.9.9;
deny 8.8.8.8;
deny 8.8.4.4;

Once done restart your Nginx server

PLAINTEXT2 lines
service nginx restart OR
service nginx reload

Great source to obtain fresh IP addresses is from Ip2location You pick and choose any country from the above link and wont allow them access to your server.

Was this worth your time?

Continue reading

Full archive

17 min read

Automating Proxmox VM Deployment

In the world of virtualization and infrastructure management, efficiency is everything. Today, I'm excited to share our latest automation script that transforms the traditionally manual process of creating virtual…

5 min read

DocFlux 2.0: A PDF Knowledge Base

In this post, I’ll walk you through the journey of building DocFlux 2.0, a robust PDF knowledge base application using Python, FastAPI, and cutting-edge NLP tools like OpenAI’s API. We’ll also cover how the frontend…