Limit to IP, redirect all others to alternate site?
Phillip Oldham
phill at activityhq.com
Tue Mar 30 13:36:37 MSD 2010
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?
More information about the nginx
mailing list