Snippets

Tjerk Ameel Nginx: Conditional HTTP Authentication

Created by Tjerk Ameel last modified
## Mapping domainnames to authentication types.
## This can be used to selectively activate http authentication for certain domains.
## See public.access for the rest of the configuration

map $host $auth_type {
  hostnames;
  default "off";

  .editionspelckmans.be   "Restricted";
  .editionspelckmans.dev  "Restricted";
}

## Mapping request URI to authentication types.
## This can be used to selectively activate http authentication for certain domains / folders.
## See public.access for the rest of the configuration

map $request_uri $auth_type {
  default "off";

  ~*^/eu/(en|fr|nl|de)/blog          "Restricted";
  ~*^/(us|world)/blog                "Restricted";

  ~*^/eu/(en|fr|nl|de)/exhibitions   "Restricted";
  ~*^/(us|world)/exhibitions         "Restricted";
}
# See http.magerunmaps for $auth_type mapping
auth_basic              $auth_type;
auth_basic_user_file    /data/web/public/.htpasswd;

allow 81.83.13.48;
allow 81.246.73.50;
allow 131.103.20.160/27;
allow 165.254.145.0/26;
allow 104.192.143.0/24;
allow 194.78.68.74;
allow 195.130.153.90;

# Allow request from self.
allow 127.0.0.1;
allow 146.185.178.248;

# Always allow computer Bram access so he can use Flash to upload files.
allow 213.224.1.194;

# Ingenico test servers
allow 212.23.45.97;
allow 212.35.124.164;

#deny all;
satisfy any;

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.