# Interner Endpunkt für die Authentifizierung
location = /auth-validate {
    internal;

    # This address is where the authentication service will be listening on
    proxy_pass http://127.0.0.1:5005/validate;
    proxy_pass_request_body off; # no need to send the POST body

    proxy_set_header Content-Length "";
    proxy_set_header X-Real-IP $remote_addr;
}

error_page 401 = @error401;

# If the user is not logged in, redirect them to the login URL
location @error401 {
    return 302 https://login.mydomain.com/?url=https://$http_host$request_uri;
}

auth_request /auth-validate;
