Last active
January 28, 2021 03:01
-
-
Save Gourds/915f2ddd96c6f6d4729165108d603ee3 to your computer and use it in GitHub Desktop.
nginx-protect-app_config
This file contains 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
server { | |
listen 2081; | |
server_name test_sso_nginx_a.taiheops.com; | |
client_max_body_size 2050m; | |
client_body_buffer_size 1024k; | |
#root /usr/share/nginx/html; | |
#index index.html; | |
#add | |
auth_request /vouch-validate; | |
location = /vouch-validate { | |
# This address is where Vouch will be listening on | |
proxy_pass http://127.0.0.1:9090/validate; | |
proxy_set_header Host $http_host; | |
proxy_pass_request_body off; # no need to send the POST body | |
proxy_set_header Content-Length ""; | |
# | |
auth_request_set $auth_resp_x_vouch_user $upstream_http_x_vouch_user; | |
# | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
# these return values are passed to the @error401 call | |
auth_request_set $auth_resp_jwt $upstream_http_x_vouch_jwt; | |
auth_request_set $auth_resp_err $upstream_http_x_vouch_err; | |
auth_request_set $auth_resp_failcount $upstream_http_x_vouch_failcount; | |
# | |
#proxy_set_header Host $http_host; | |
} | |
error_page 401 = @error401; | |
# If the user is not logged in, redirect them to Vouch's login URL | |
location @error401 { | |
#return 302 https://vouch.yourdomain.com/login?url=$scheme://$http_host$request_uri&vouch-failcount=$auth_resp_failcount&X-Vouch-Token=$auth_resp_jwt&error=$auth_resp_err; | |
return 302 http://vouch.taiheops.com:2081/login?url=$scheme://$http_host$request_uri&vouch-failcount=$auth_resp_failcount&X-Vouch-Token=$auth_resp_jwt&error=$auth_resp_err; | |
} | |
#location ~ ^/(auth|login|logout|static) { | |
# proxy_pass http://127.0.0.1:9090; | |
# proxy_set_header Host $http_host; | |
# } | |
location / { | |
# forward authorized requests to your service protectedapp.yourdomain.com | |
#proxy_pass http://127.0.0.1:8080; | |
proxy_pass http://172.16.1.103:3000; | |
# you may need to set these variables in this block as per https://github.com/vouch/vouch-proxy/issues/26#issuecomment-425215810 | |
# auth_request_set $auth_resp_x_vouch_user $upstream_http_x_vouch_user | |
# auth_request_set $auth_resp_x_vouch_idp_claims_groups $upstream_http_x_vouch_idp_claims_groups; | |
# auth_request_set $auth_resp_x_vouch_idp_claims_given_name $upstream_http_x_vouch_idp_claims_given_name; | |
# set user header (usually an email) | |
proxy_set_header X-Vouch-User $auth_resp_x_vouch_user; | |
# optionally pass any custom claims you are tracking | |
# proxy_set_header X-Vouch-IdP-Claims-Groups $auth_resp_x_vouch_idp_claims_groups; | |
# proxy_set_header X-Vouch-IdP-Claims-Given_Name $auth_resp_x_vouch_idp_claims_given_name; | |
# optionally pass the accesstoken or idtoken | |
# proxy_set_header X-Vouch-IdP-AccessToken $auth_resp_x_vouch_idp_accesstoken; | |
# proxy_set_header X-Vouch-IdP-IdToken $auth_resp_x_vouch_idp_idtoken; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment