Created
December 29, 2021 00:16
-
-
Save vik407/5fa7b29d7ca60ffdffe48240b537e050 to your computer and use it in GitHub Desktop.
Nginx - Whitelist IPs to access a url
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| location /admin { | |
| error_page 403 = @deny; // Return forbidden and redirect | |
| allow 127.0.0.1; | |
| allow 192.168.0.1; | |
| deny all; | |
| try_files $uri $uri/ /index.php?$query_string; // Important for PHP rewrite cond ej (index.php/admin) | |
| } | |
| location @deny { | |
| return 301 http://example.com; // The redirect URL | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment