Skip to content
Menu
vernon.wenberg.net
vernon.wenberg.net
January 16, 2024January 16, 2024

Only allow certain IPs to access your Apache2/nginx web server

Use the following statements in your conf files. IPs are in CIDR format. Replace with your IP ranges as needed.

Apache 2.4

<FilesMatch ".*">
    Require ip 192.88.134.0/23
    Require ip 185.93.228.0/22
    Require ip 2a02:fe80::/29
    Require ip 66.248.200.0/22
    Require ip 208.109.0.0/22
</FilesMatch>

Apache 2.2

<FilesMatch ".*">
    Order deny,allow
    Deny from all
    Allow from 192.88.134.0/23
    Allow from 185.93.228.0/22
    Allow from 2a02:fe80::/29
    Allow from 66.248.200.0/22
    Allow from 208.109.0.0/22
</FilesMatch>

nginx

location / {
    allow 192.88.134.0/23;
    allow 185.93.228.0/22;
    allow 2a02:fe80::/29;
    allow 66.248.200.0/22;
    allow 208.109.0.0/22;
    deny all;
    # Existing NGINX rules
}

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to print (Opens in new window) Print
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn

Like this:

Like Loading...

Related

Disclaimer

These posts are notes for me. These are not guides and you should not use these instructions as step-by-step instructions without knowing what they do.

Recent Posts

  • HPE Aruba-CX Notes
  • Docker Reference
  • Useful Commands for Windows Subsystem for Linux
  • FortiManager Local-In Policy
  • Mount Google Drive in Linux using rclone

Mastodon

  1. Loading Mastodon feed...

©2025 vernon.wenberg.net | Powered by WordPress and Superb Themes!
%d