Skip to content

Instantly share code, notes, and snippets.

@vik407
Created December 29, 2021 00:16
Show Gist options
  • Save vik407/5fa7b29d7ca60ffdffe48240b537e050 to your computer and use it in GitHub Desktop.
Save vik407/5fa7b29d7ca60ffdffe48240b537e050 to your computer and use it in GitHub Desktop.
Nginx - Whitelist IPs to access a url
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