Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to get rid of the if? #276

Open
androos opened this issue Aug 6, 2017 · 4 comments
Open

Is it possible to get rid of the if? #276

androos opened this issue Aug 6, 2017 · 4 comments

Comments

@androos
Copy link

androos commented Aug 6, 2017

https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/

Nginx and 'if' is evil. I wonder if there is any method to get rid of all the if statements?

@jmtorres
Copy link

The only sections that seem to have if statements are in low traffic admin locations and in the hot linking protection that is not enabled by default. These should not be in the flow for other requests. Are there others that I missed?

@androos
Copy link
Author

androos commented Aug 18, 2017

## See the blacklist.conf file at the parent dir: /etc/nginx.
## Deny access based on the User-Agent header.
if ($bad_bot) {
    return 444;
}
## Deny access based on the Referer header.
if ($bad_referer) {
    return 444;
}

## Protection against illegal HTTP methods. Out of the box only HEAD,
## GET and POST are allowed.
if ($not_allowed_method) {
    return 405;
}

@jmtorres
Copy link

Those Ifs are not considered evil as they are directly in the server block, only evaluate a mapped variable set in the http block, and only returns an error code or stops processing altogether (444).

@smhanes15
Copy link

More specifically, the first line of the linked resource states: "Directive if has problems when used in location context...". Emphasis added is mine.

None of the if directives Perusio has setup are within a location block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants