Welcome! Log In Create A New Profile

Advanced

Re: NGINX - forbidden custom message

António P. P. Almeida
March 03, 2012 12:38PM
On 3 Mar 2012 16h07 CET, nginx-forum@nginx.us wrote:

> sorry for being so direct but this is what I need to do...
>
> in one of my virtual hosts I need to show a custom message based on
> user's IP.
>
> for example...
>
> if user comes from 1.0.0.0/8 or 12.0.0.0/8 it get a custom
> message/page yet if user comes from anywhere else he'll be able to
> use site normally

> how would I accomplish that?

+ 1st option

At the http level:

geo $forbidden_client {
default 0;
1.0.0.0/8 1;
12.0.0.0/8 1;
}

server {
# ...

error_page 418 /custom_message.html;

if ($forbidden_client) {
return 418;
}
}


+ 2nd option


server {
# ...

error_page 403 /custom_message.html;

deny 1.0.0.0/8;
deny 12.0.0.0/8;
allow all;
}

--- appa

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

NGINX - forbidden custom message

alexus March 03, 2012 10:07AM

Re: NGINX - forbidden custom message

António P. P. Almeida March 03, 2012 12:38PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 267
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