Skip to content

Instantly share code, notes, and snippets.

@micw
Last active April 27, 2018 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micw/00659522bc1ef64257006c1cc6da3d24 to your computer and use it in GitHub Desktop.
Save micw/00659522bc1ef64257006c1cc6da3d24 to your computer and use it in GitHub Desktop.
Nginx auth with login-form passthrough
# This variant uses the same endpoint for the check and the login form
server {
listen 80;
server_name localhost;
location = /internal-nginx-auth-endpoint {
internal;
proxy_pass http://172.17.0.1:8080/;
}
error_page 401 = /internal-nginx-auth-endpoint;
location / {
auth_request /internal-nginx-auth-endpoint;
}
}
# This variant uses the a minimal endpoint for the check and a different one for the login form
server {
listen 80;
server_name localhost;
location = /internal-nginx-auth-login-endpoint {
internal;
proxy_pass http://172.17.0.1:8080/login;
}
location = /internal-nginx-auth-check-endpoint {
internal;
proxy_pass http://172.17.0.1:8080/check;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
}
error_page 401 = /internal-nginx-auth-login-endpoint;
location / {
auth_request /internal-nginx-auth-check-endpoint;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment