Skip to content

Instantly share code, notes, and snippets.

@lamanotrama
Created January 13, 2016 05:45
Show Gist options
  • Save lamanotrama/eab1a0f5ac3c90194a88 to your computer and use it in GitHub Desktop.
Save lamanotrama/eab1a0f5ac3c90194a88 to your computer and use it in GitHub Desktop.
oauth2_proxy + nginx auth_requstのサンプルだよ
# please include in server context
# ref: https://github.com/bitly/oauth2_proxy#endpoint-documentation
# for checking login status.
# only returns a 202 Accepted response or a 401 Unauthorized response;
location = /oauth2/auth {
internal;
# return 202 if local request, for inftataster test
set $local 0;
if ($remote_addr = "127.0.0.1") { set $local 1; }
if ($remote_addr ~* "^172\.17\.") { set $local 1; }
if ($remote_addr ~* "^192\.168") { set $local 1; }
if ($local = 1) { return 202; }
proxy_pass http://127.0.0.1:4190;
proxy_set_header Host $host;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
}
# to start oauth cycle
location = /oauth2/start {
internal;
proxy_pass http://127.0.0.1:4190;
proxy_set_header Host $host;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
}
# to complete oauth cycle
location = /oauth2/callback {
auth_request off;
proxy_pass http://127.0.0.1:4190;
proxy_set_header Host $host;
}
@glidenote
Copy link

great document 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment