Last active
January 4, 2021 06:33
-
-
Save Lax/b7f57a14e8d1ec40a8ff808722ab870f to your computer and use it in GitHub Desktop.
User-Agent based ACL - conditional redirecting rules
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
log_format client_ip "$remote_addr"; | |
map $http_user_agent $whitelist_ua { | |
default 1; | |
"~*curl" 0; | |
} | |
server { | |
listen 80; | |
access_log off; | |
if ($whitelist_ua) { | |
rewrite ^/.* https://v.mib.cc redirect; | |
} | |
location / { | |
access_log /var/log/nginx/client_ip.log client_ip; | |
return 200 "OK\nHello world!\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment