45 lines
1.5 KiB
Nginx Configuration File
45 lines
1.5 KiB
Nginx Configuration File
# Reverse proxy to httpbin
|
|
server {
|
|
listen 8080;
|
|
server_name oauth2-proxy.localtest.me;
|
|
|
|
location /oauth2/ {
|
|
proxy_pass http://oauth2-proxy:4180;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-Uri $request_uri;
|
|
proxy_set_header X-Auth-Request-Redirect $request_uri;
|
|
}
|
|
|
|
location = /oauth2/auth {
|
|
proxy_pass http://oauth2-proxy:4180;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-Uri $request_uri;
|
|
# nginx auth_request includes headers but not body
|
|
proxy_set_header Content-Length "";
|
|
proxy_pass_request_body off;
|
|
}
|
|
|
|
location / {
|
|
auth_request /oauth2/auth;
|
|
error_page 401 = @oauth2_signin;
|
|
|
|
# pass information via X-User and X-Email headers to backend,
|
|
# requires running with --set-xauthrequest flag
|
|
auth_request_set $user $upstream_http_x_auth_request_user;
|
|
auth_request_set $email $upstream_http_x_auth_request_email;
|
|
proxy_set_header X-User $user;
|
|
proxy_set_header X-Email $email;
|
|
|
|
proxy_pass http://httpbin/;
|
|
# or "root /path/to/site;" or "fastcgi_pass ..." etc
|
|
}
|
|
|
|
# Named location for handling OAuth2 sign-in redirects
|
|
# This ensures the browser receives a proper 302 redirect that it will follow
|
|
location @oauth2_signin {
|
|
return 302 /oauth2/sign_in?rd=$scheme://$http_host$request_uri;
|
|
}
|
|
}
|