Is it possible to configure nginx so that ALL websites are only accessible from the office IP address only?
This is a development server that, on some sites (too many to block one by one) accidentaly has some views and activity going and I want to block everyones' access except the people in the office which come from the office IP.
Is there any way to that?
Why it needs firewall?
allow/deny
directives can be used not only inlocation
sections, but inhttp
section too.Sounds more like a work for a firewall. Assuming you are running Linux you could use iptables.
I'd use iptables to block port 80 for all IPs except your office.
As mentionned,
iptables
is an option.As an alternative you can use the Nginx
ngx_http_access_module
to restrict access.E.g assuming your office network is
192.168.1.0/24
:Or
Note : using this approach, users with IPs not allowed will get a
403
, not a "site unreachable".http://nginx.org/en/docs/http/ngx_http_access_module.html