For my site I'd like to be able to put up a maintenance 503 page but with a whitelist of ip-addresses that will be able to use the website as normal
Would I have to craft something like this in lua?
I see some questions like
Nginx Ip Whitelist
and
How can I setup a custom 503 error page in NGINX?
which explain how to do this separately but I'd like to kind of combine them so I could take the site offline for the outside world but still be able to test it normally from certain IP addresses
You could use the ngx_http_geo_module:
geo $denied {
default 1; # nobody is allowed access by default
# but people from the following networks/ip addresses are allowed access
include whitelist;
127.0.0.1 0;
192.168.1.0/24 0;
}
server {
location / {
if ($denied) {
return 503;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With