Created
October 16, 2017 21:11
-
-
Save sergeyhush/821f10f80b71d75efd2b736ba17d4c50 to your computer and use it in GitHub Desktop.
NGINX allow/block location by request method and IP
This file contains 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
geo $allow_client { | |
default no; | |
10.0.1.183 yes; | |
} |
This file contains 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
include /etc/nginx/conf.d/allow_clients.conf; | |
server { | |
location /x { | |
set $postall ""; | |
if ($request_method = POST) { | |
set $postallow "post${allow_client}; | |
} | |
if ($postallow = postno) { | |
return 403; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment