Skip to content

Instantly share code, notes, and snippets.

@sergeyhush
Created October 16, 2017 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergeyhush/821f10f80b71d75efd2b736ba17d4c50 to your computer and use it in GitHub Desktop.
Save sergeyhush/821f10f80b71d75efd2b736ba17d4c50 to your computer and use it in GitHub Desktop.
NGINX allow/block location by request method and IP
geo $allow_client {
default no;
10.0.1.183 yes;
}
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