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?