Welcome! Log In Create A New Profile

Advanced

Limit to IP, redirect all others to alternate site?

Phillip Oldham
March 30, 2010 05:40AM
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@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Limit to IP, redirect all others to alternate site?

Phillip Oldham March 30, 2010 05:40AM

Re: Limit to IP, redirect all others to alternate site?

Phillip Oldham March 30, 2010 05:48AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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