2

As I explained in title I want to restrict access unless the header is satisfied. In the given link, it is explained how to restrict a specific path access, however I couldn't find anything about how to add conditions to this restriction from my researches. Any idea about this problem?

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37

2 Answers2

0

Instead of deny/allow directives you can check any HTTP header value via $http_<name> variable and use return 403 to forbid access. For example, lets call our header X-Secret-Token:

location /some/path {
    if ($http_x_secret_token != 'my-super-secret-password') {
        return 403; # HTTP 403 Forbidden, the same code as generated by 'deny' directive
    }
    ...
}

If you need some complex checks, you can use several chained map blocks (see the example).

Ivan Shatsky
  • 13,267
  • 2
  • 21
  • 37
0

From the research I've made it seems like the token approach presented here before seems to be the only suitable solution, a similar question has been asked here.

Jakub Siemaszko
  • 668
  • 3
  • 8