Welcome! Log In Create A New Profile

Advanced

how to block a particular URL in nginx

how to block a particular URL in nginx
April 21, 2015 02:03AM
Hi,

I have a nginx conf file in which i want to block this particular url example-xyz.com.

I have added the following lines in my conf file.

server {
port_in_redirect off;
server_tokens off;
if ($http_host$request_uri != 'example-xyz.com') {
return 403;
break;
}
listen 80;
}

But this is not working, everytime i hit this url in my browser, it is opening fine.
Ideally it should return access forbidden.

Any suggestions.
Re: how to block a particular URL in nginx
April 21, 2015 02:07AM
A little modification.

server {
port_in_redirect off;
server_tokens off;
if ($http_host$request_uri = 'example-xyz.com') {
return 403;
break;
}
listen 80;
}
Re: how to block a particular URL in nginx
April 21, 2015 04:10AM
Get the latest version here http://nginx-win.ecsds.eu/
Then look in the /conf/ folder at nginx-simple-WAF.conf
on how to do this with map and using wildcards (regx).

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 85
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready