Created
January 25, 2013 19:42
-
-
Save Coopeh/4637216 to your computer and use it in GitHub Desktop.
How to use multiple if statements in Nginx
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
set $posting 0; # Make sure to declare it first to stop any warnings | |
if ($request_method = POST) { # Check if request method is POST | |
set $posting N; # Initially set the $posting variable as N | |
} | |
if ($geoip_country_code ~ (BR|CN|KR|RU|UA) ) { # Here we're using the Nginx GeoIP module to block some spammy countries | |
set $posting "${posting}O"; # Set the $posting variable to itself plus the letter O | |
} | |
if ($posting = NO) { # We're looking if both of the above rules are set to spell NO | |
return 403; # If it is then let's block them! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment