# Safe to call ngx\_http\_subrequest inside location handler?

**URL:** <https://www.ruby-forum.com/t/safe-to-call-ngx-http-subrequest-inside-location-handler/235048>\
**Category:** NGINX\
**Created:** [May 28, 2013, 10:03am UTC](https://www.ruby-forum.com/t/safe-to-call-ngx-http-subrequest-inside-location-handler/235048 "2013-05-28T10:03:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [May 28, 2013, 10:03am UTC](https://www.ruby-forum.com/t/safe-to-call-ngx-http-subrequest-inside-location-handler/235048/1 "2013-05-28T10:03:55Z")

</div>

Hello,

So according to evan miller’s tutorial and nginx’s own source code, it  
seems  
only filters can send subrequests. But I have tried to call  
ngx\_http\_subrequest inside my location handler, and everything seems  
working  
fine. I am using version 1.2.8.

Just want to ask and see if it’s safe to do so.

Thanks a lot!

Posted at Nginx Forum:

> **[safe to call ngx\_http\_subrequest inside location handler?](https://forum.nginx.org/read.php?2,239619,239619#msg-239619)**
>
> Hello, So according to evan miller's tutorial and nginx's own source code, it seems only filters can send subrequests. But I have tried to call ngx\_http\_subrequest inside my location handler, and everything seems working fine. I am using version...

---

<div class="post-metadata">

**Author:** ![jesse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jesse](https://www.ruby-forum.com/u/jesse)\
**Post date:** [May 28, 2013, 12:55pm UTC](https://www.ruby-forum.com/t/safe-to-call-ngx-http-subrequest-inside-location-handler/235048/2 "2013-05-28T12:55:43Z")

</div>

Hello!

On Tue, May 28, 2013 at 04:03:07AM -0400, jesse wrote:

> Hello,
> 
> So according to evan miller’s tutorial and nginx’s own source code, it seems  
> only filters can send subrequests. But I have tried to call  
> ngx\_http\_subrequest inside my location handler, and everything seems working  
> fine. I am using version 1.2.8.
> 
> Just want to ask and see if it’s safe to do so.

This mostly works since 0.7.25. There are some subtleties with  
request body handling though.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**

---

<div class="post-metadata">

**Author:** ![jesse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jesse](https://www.ruby-forum.com/u/jesse)\
**Post date:** [May 28, 2013, 7:20pm UTC](https://www.ruby-forum.com/t/safe-to-call-ngx-http-subrequest-inside-location-handler/235048/3 "2013-05-28T19:20:11Z")

</div>

I see. Thanks, Maxim!

Posted at Nginx Forum:

> **[Re: safe to call ngx\_http\_subrequest inside location handler?](https://forum.nginx.org/read.php?2,239619,239635#msg-239635)**
>
> Hello, So according to evan miller's tutorial and nginx's own source code, it seems only filters can send subrequests. But I have tried to call ngx\_http\_subrequest inside my location handler, and everything seems working fine. I am using version...
