rewrite every req to xxx.html unless coming from xxx.xxx.xxx.xxx ?

Maxim Dounin mdounin at mdounin.ru
Thu Jun 25 20:39:17 MSD 2009


Hello!

On Thu, Jun 25, 2009 at 01:03:24PM +0800, Pahud wrote:

> Hi,
> 
> I'd like to rewrite every request to xxx.html unless they are coming from my
> 2 trusted IP addresses. What can I do?
> 
> In the mean time, I need to avoid the loop to request the xxx.html.
> 
> Any example appreciated.

Something like this should work:

    location / {
        error_page 403 =200 /xxx.html;

        allow 1.2.3.4;
        allow 1.2.3.5;
        deny all;

        ...
    }

    location = /xxx.html {
        # an empty location without access checks
    }

Maxim Dounin

> 
> pahud





More information about the nginx mailing list