Advertisement
Guest User

code

a guest
Apr 12th, 2024
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. # Increase buffer size for large headers
  2. # This is needed only if you get 'upstream sent too big header while reading response
  3. # header from upstream' error when trying to access an application protected by goauthentik
  4. proxy_buffers 8 16k;
  5. proxy_buffer_size 32k;
  6.  
  7. # Make sure not to redirect traffic to a port 4443
  8. port_in_redirect off;
  9.  
  10. location / {
  11. # Put your proxy_pass to your application here
  12. proxy_pass $forward_scheme://$server:$port;
  13. # Set any other headers your application might need
  14. proxy_set_header Host $host;
  15. # proxy_set_header ...
  16.  
  17. ##############################
  18. # authentik-specific config
  19. ##############################
  20. auth_request /outpost.goauthentik.io/auth/nginx;
  21. error_page 401 = @goauthentik_proxy_signin;
  22. auth_request_set $auth_cookie $upstream_http_set_cookie;
  23. add_header Set-Cookie $auth_cookie;
  24.  
  25. # translate headers from the outposts back to the actual upstream
  26. auth_request_set $authentik_username $upstream_http_x_authentik_username;
  27. auth_request_set $authentik_groups $upstream_http_x_authentik_groups;
  28. auth_request_set $authentik_email $upstream_http_x_authentik_email;
  29. auth_request_set $authentik_name $upstream_http_x_authentik_name;
  30. auth_request_set $authentik_uid $upstream_http_x_authentik_uid;
  31. auth_request_set $authentik_auth $upstream_http_authorization;
  32.  
  33. proxy_set_header X-authentik-username $authentik_username;
  34. proxy_set_header X-authentik-groups $authentik_groups;
  35. proxy_set_header X-authentik-email $authentik_email;
  36. proxy_set_header X-authentik-name $authentik_name;
  37. proxy_set_header X-authentik-uid $authentik_uid;
  38. proxy_set_header Authorization $authentik_auth;
  39.  
  40. }
  41.  
  42. # all requests to /outpost.goauthentik.io must be accessible without authentication
  43. location /outpost.goauthentik.io {
  44. proxy_pass http://192.168.10.200:9000/outpost.goauthentik.io;
  45. # ensure the host of this vserver matches your external URL you've configured
  46. # in authentik
  47. proxy_set_header Host $host;
  48. proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
  49. add_header Set-Cookie $auth_cookie;
  50. auth_request_set $auth_cookie $upstream_http_set_cookie;
  51. proxy_pass_request_body off;
  52. proxy_set_header Content-Length "";
  53. }
  54.  
  55. # Special location for when the /auth endpoint returns a 401,
  56. # redirect to the /start URL which initiates SSO
  57. location @goauthentik_proxy_signin {
  58. internal;
  59. add_header Set-Cookie $auth_cookie;
  60. return 302 /outpost.goauthentik.io/start?rd=$request_uri;
  61. # For domain level, use the below error_page to redirect to your authentik server with the full redirect path
  62. # return 302 https://authentik.company/outpost.goauthentik.io/start?rd=$scheme://$http_host$request_uri;
  63. }
  64.  
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement