I'm trying to switch some stuff over to a domain running nginx. Is there a simple way to just put my ip address in the configuration for the subdomain and say "If ip is not mine, then just serve this html file. Otherwise, act like normal"?
Asked
Active
Viewed 1,292 times
1 Answers
2
You can tackle this by using IP based maintenance triggers
Try the following at the bottom of here: http://forum.nginx.org/read.php?2,88978,91161
You could just do it like this in the global section:
geo $maintenance { default 0;
80.15x.yy.zz/29 0; # your IPs still allowed
80.15x.yy.zz/29 0; # another bunch of allowed IPs }
and in the server section add this:
if ($maintenance) { rewrite ^(.*)$
/yourmaintenancefile.html last; }
When you want to start maintenance just switch the "default 0;" to "default 1;" in the $maintenance block and reload your nginx.
Have a look at http://wiki.nginx.org/NginxHttpGeoModule

anthonysomerset
- 4,233
- 2
- 21
- 24