Nginx 재작성 및 반환이 다른 위치 블록을 방해합니다.

Nginx 재작성 및 반환이 다른 위치 블록을 방해합니다.

특정 시나리오에서 리디렉션을 위해 nginx에 다음 구성이 있습니다.

location /prefix-someurl {
   if (condition) {
            return 301 $scheme://$host/xyz.html;
   }
   proxy_pass someValue;
}

그리고 다른 블록에는 다음과 같은 재작성 규칙이 있습니다.

location /someurl {
   if (condition) {
            rewrite ^(.*)abc(.*)$ $1test/abc$2 break;               
            rewrite ^(.*)someurl/$(.*) $1someurl/test/index.html$2;

   }
   proxy_pass value;
}

위 구성은 의도한 대로 작동합니다. 그러나 후자의 경우 이렇게 수정합니다.

location /someurl {
   if (condition) {
            return 301 $scheme://$host/xyz.html;
   }
   if (condition) {
            rewrite ^(.*)abc(.*)$ $1test/abc$2 break;               
            rewrite ^(.*)someurl/$(.*) $1someurl/test/index.html$2;

   }
   proxy_pass value;
}

액세스할 때 리디렉션 오류가 너무 많이 발생합니다./prefix-someurl.다음과 같이 수정하면 /someurl오류가 사라집니다.

location /someurl {
  if (condition) {
        return 301 $scheme://$host/xyz.html;
  }    
  proxy_pass value;
}

수정 /someurl/prefix-someurl. 아니면 nginx 재작성 평가와 관련하여 뭔가 빠졌나요? 이에 대한 통찰력을 높이 평가하겠습니다.

관련 정보