Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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"?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.