Skip to content

Instantly share code, notes, and snippets.

@kasparsd
Created February 21, 2017 13:40
Show Gist options
  • Select an option

  • Save kasparsd/62816bd0f92e152c6c613a5b97f1642d to your computer and use it in GitHub Desktop.

Select an option

Save kasparsd/62816bd0f92e152c6c613a5b97f1642d to your computer and use it in GitHub Desktop.
Nginx HTTP basic auth with cookie pass
map $cookie_skip_http_auth $auth_type {
default "Restricted Area";
"123" "off";
}
server {
location /setauthcookie {
add_header Set-Cookie "skip_http_auth=123";
return 301 http://example.com;
}
location / {
auth_basic $auth_type;
auth_basic_user_file "/etc/nginx/auth.passwords";
try_files $uri $uri/ =404;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment