Using Nginx 1.4.6, Ubuntu 14.04 LTS. I have this in the http section of nginx.conf
:
geo $maintenance {
default 1;
86.161.27.175 0;
}
In my site config I have this:
error_page 503 /static/errors/503.html;
location /mydir/ {
if ($maintenance) {
return 503;
}
try_files $uri $uri/ =404;
}
However, I am always getting a 503 error when viewing /mydir/
on my site, but for my IP that shouldn't be happening. I've double checked and that is definitely my current IP. I have another geo section for rate limiting that is working fine. Manually setting $maintenance
to 0 just above the location block works fine.
Why is this not working?
Found the problem: I had CloudFlare turned on for my staging site, so it was receiving a CloudFlare IP, not my actual IP. D'oh!