Created
February 21, 2017 13:40
-
-
Save kasparsd/62816bd0f92e152c6c613a5b97f1642d to your computer and use it in GitHub Desktop.
Nginx HTTP basic auth with cookie pass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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