add_header применится в location{}, только если в location{} не определены другие add_header.There could be several add_header directives. These directives are inherited from the previous level if and only if there are no add_header directives defined on the current level.
deny IP;
deny subnet; (если у вас nginx фронтом стоит, я надеюсь)