ngx_http_internal_redirect_module
모듈 ngx_http_internal_redirect_module
(1.23.4)을 사용하면 내부 리다이렉션(internal redirect)을 수행할 수 있습니다. Urewriting_URIs 것과 달리 request 및 connection 처리 제한, access 제한을 확인한 후 리다이렉션이 이루어집니다 .
예제 구성
limit_req_zone $jwt_claim_sub zone=jwt_sub:10m rate=1r/s;
server {
location / {
auth_jwt "realm";
auth_jwt_key_file key.jwk;
internal_redirect @rate_limited;
}
location @rate_limited {
internal;
limit_req zone=jwt_sub burst=10;
proxy_pass http://backend;
}
}
이 예에서는 per-user rate limiting 구현합니다 . Internal_redirect 없이 구현하면 서명되지 않은 JWT에 의한 DoS 공격에 취약합니다. 일반적으로 auth_jwt 확인 전에 Limit_req 확인이 수행되기 때문입니다 . Internal_redirect를 사용하면 이러한 검사의 순서를 변경할 수 있습니다.
Directives
Syntax: internal_redirect uri;
Default: —
Context: http, location
요청의 내부 리다이렉션을 위한 URI를 설정합니다. URI 대신 named location 사용하는 것도 가능합니다 . 값 uri
에는 변수가 포함될 수 있습니다. uri
값이 비어 있으면 리다이렉션이 수행되지 않습니다.