I'm trying to configure Nginx + nginx-auth-jwt (from alpine registry) with the multiple locations:
/serving React application- 3 REST APIs each with
auth_jwt "closed site"; auth_jwt_key_request /_jwks_uri; - 1 exact location (almost identical configuration, without trailing slash, and
$usernamein the path)
location = /auth/users { auth_jwt "closed site"; auth_jwt_key_request /_jwks_uri; proxy_pass ${AUTH_HTTPS_URL}/some/path/$username/info; proxy_set_header api-key ${SOME_API_KEY}; 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; proxy_read_timeout ${SOME_TIME}; } Before the locations I have the following:
auth_jwt_claim_set $username ${JWT_USERNAME_CLAIM}; resolver ${NGINX_DNS_RESOLVER}; All of the variables are populated by envsubst-on-templates.sh as in the official Nginx docker image.
With the same values (even the same .conf file with different resolver) everything works locally, but when deployed in k8s the /auth/users returns 403 without response body.
The only way I was able to reproduce 403 locally is when change the ${JWT_USERNAME_CLAIM} value, so that $username is an empty string, but this way I receive back the response from the AUTH_HTTPS_URL upstream. From the k8s deployment the response body is empty
- If the token is invalid/expired the endpoint returns 401 Unauthorized
- The responses from the 3 APIs work just fine with the very same token