<div dir="ltr">Get it, thanks for your explanation.<div><br></div><div>I faced it by the following usage of lua, and I think it's resonable for developers.</div><div><br></div><div>location /test {</div><div> content_by_lua_block {</div><div> local res = ngx.location.capture("/other"); -- post subrequest</div><div> }</div><div>}</div><div><br></div><div>location /other {</div><div> access_by_lua_block {</div><div> ...</div><div> }</div><div>}</div><div><br></div><div>It's ok for us to replace it with rewrite.<br></div><div>Anyway, do you still think it's better to restrict subrequests in access phase handler?<br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 24, 2018 at 10:06 PM Maxim Dounin <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello!<br>
<br>
On Mon, Dec 24, 2018 at 03:38:00AM +0800, 洪志道 wrote:<br>
<br>
> Hi.<br>
> <br>
> I'm wondering the reason of ignoring subrequests in access phase hander.<br>
> Can anyone explain it to me?<br>
> <br>
> 1069 ngx_int_t<br>
> 1070 ngx_http_core_access_phase(ngx_http_request_t *r,<br>
> ngx_http_phase_handler_t *ph)<br>
> 1071 {<br>
> 1072 ngx_int_t rc;<br>
> 1073 ngx_http_core_loc_conf_t *clcf;<br>
> 1074<br>
> 1075 if (r != r->main) {<br>
> 1076 r->phase_handler = ph->next;<br>
> 1077 return NGX_AGAIN;<br>
> 1078 }<br>
> 1079<br>
<br>
Access checks are expected to apply to the main request, but make <br>
little to no sense for subrequests. E.g., if you are using <br>
IP-based restrictions or Basic HTTP authentication, both are <br>
exactly identical for the main request and subrequests. As such, <br>
it is enough to do the checks for the main request only, and this <br>
is what nginx does.<br>
<br>
Note that it implies that access restrictions configured for the <br>
main requests are expected to be enough for all subrequests it can <br>
initiate.<br>
<br>
-- <br>
Maxim Dounin<br>
<a href="http://mdounin.ru/" rel="noreferrer" target="_blank">http://mdounin.ru/</a><br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org" target="_blank">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a></blockquote></div>