# Nginx Deny From IP

URL: https://sohaib.com/blog/nginx-deny-from-ip
Author: Sohaib Khan
Published: Jul 12, 2015
Updated: Sep 8, 2026
Category: Web Servers & DevOps

> 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…

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](https://www.dropbox.com/s/5ziaytlidtam9b5/nginx.zip?dl=0) which comes with all the necessary modules known to **[NGINX](https://www.dropbox.com/s/5ziaytlidtam9b5/nginx.zip?dl=0)**.

```plaintext
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

```plaintext
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

```plaintext
service nginx restart OR
service nginx reload
```

Great source to obtain fresh IP addresses is from **[Ip2location](http://www.ip2location.com/free/visitor-blocker)** You pick and choose any country from the above link and wont allow them access to your server.
