Limit to IP, redirect all others to alternate site?
Phillip Oldham
phill at activityhq.com
Tue Mar 30 13:43:37 MSD 2010
Actually, just saw that error_page can take a URL as an argument.
Changed to the following:
server {
error_page 403 http://foo.com;
location / {
allow 1.1.1.1;
deny all;
}
}
Works perfectly.
Thanks!
On 30/03/2010 10:36, Phillip Oldham wrote:
> How would I limit a virtual host to a single IP and redirect all other
> IPs to an alternate domain/website? I'm using the http_access module
> to limit IPs which returns a 403, but I'd prefer that nginx return a
> "location" header to bounce visitors to http://foo.com.
>
> At the moment I've got this:
>
> server {
> if ( $remote_addr != 1.1.1.1 ) {
> rewrite ^ http://foo.com last;
> }
>
> location / {
> allow 1.1.1.1;
> deny all;
> }
> }
>
> but that feels quite "hacky". Is there a better format?
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>
More information about the nginx
mailing list