Skip to content

Commit f4c3566

Browse files
authored
Merge pull request bitly#382 from ploxiln/auth_request_readme
README: nginx auth_request example updates
2 parents ea2540b + 6d295f8 commit f4c3566

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

README.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -350,15 +350,10 @@ The [Nginx `auth_request` directive](http://nginx.org/en/docs/http/ngx_http_auth
350350

351351
```nginx
352352
server {
353-
listen 443 ssl spdy;
353+
listen 443 ssl;
354354
server_name ...;
355355
include ssl/ssl.conf;
356356
357-
location = /oauth2/auth {
358-
internal;
359-
proxy_pass http://127.0.0.1:4180;
360-
}
361-
362357
location /oauth2/ {
363358
proxy_pass http://127.0.0.1:4180;
364359
proxy_set_header Host $host;
@@ -367,7 +362,7 @@ server {
367362
proxy_set_header X-Auth-Request-Redirect $request_uri;
368363
}
369364
370-
location /upstream/ {
365+
location / {
371366
auth_request /oauth2/auth;
372367
error_page 401 = /oauth2/sign_in;
373368
@@ -378,14 +373,12 @@ server {
378373
proxy_set_header X-User $user;
379374
proxy_set_header X-Email $email;
380375
381-
proxy_pass http://backend/;
382-
}
376+
# if you enabled --cookie-refresh, this is needed for it to work with auth_request
377+
auth_request_set $auth_cookie $upstream_http_set_cookie;
378+
add_header Set-Cookie $auth_cookie;
383379
384-
location / {
385-
auth_request /oauth2/auth;
386-
error_page 401 = https://example.com/oauth2/sign_in;
387-
388-
root /path/to/the/site;
380+
proxy_pass http://backend/;
381+
# or "root /path/to/site;" or "fastcgi_pass ..." etc
389382
}
390383
}
391384
```

0 commit comments

Comments
 (0)