# Using upstream module that won't override the original request

**URL:** <https://www.ruby-forum.com/t/using-upstream-module-that-wont-override-the-original-request/228224>\
**Category:** NGINX\
**Created:** [April 14, 2013, 3:23pm UTC](https://www.ruby-forum.com/t/using-upstream-module-that-wont-override-the-original-request/228224 "2013-04-14T15:23:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gadh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19adc/32.png) [@gadh](https://www.ruby-forum.com/u/gadh)\
**Post date:** [April 14, 2013, 3:23pm UTC](https://www.ruby-forum.com/t/using-upstream-module-that-wont-override-the-original-request/228224/1 "2013-04-14T15:23:13Z")

</div>

I’m trying to hold a client request to backend (not go to the server  
yet),  
issue an upstream request to another server, then parse the upstream  
response, store it in my orig. request ctx, only then go to backend  
server  
(original request), and in the output filter inject some of the ctx data  
i  
stored before - to the backend response.

i tried to do all that with a subrequest but then Maxim told me that the  
subrequest was not designed for that - hence no support in my method.  
Now if i use upstream instead - it overrides the original request and  
sends  
its own response to the client.  
so how can i achieve my goal ?

Ref:  
see Maxim’s response to a similar thread here:  
[http://web.archiveorange.com/archive/v/yKUXMonlhsVD7yQtg8xL](http://web.archiveorange.com/archive/v/yKUXMonlhsVD7yQtg8xL)  
see my new subrequest method & discussion here:

> **[nginx + my module crashes only when ignore client abort = on](https://forum.nginx.org/read.php?2,237362)**
>
> i use nginx ver 1.2.5 (also tried 1.2.7) with my module that sends subrequest to an upstream, waits untill response get back, then goes to backend upstream and fetch the regular web page from it. when i add to nginx conf...

(nginx core crashes when using my method + flag of ‘ignore client  
abort’=on  
and no solution from nginx developers for that)

Posted at Nginx Forum:

> **[using upstream module that won't override the original request](https://forum.nginx.org/read.php?2,238355,238355#msg-238355)**
>
> I'm trying to hold a client request to backend (not go to the server yet), issue an upstream request to another server, then parse the upstream response, store it in my orig. request ctx, only then go to backend server (original request), and in the...

---

<div class="post-metadata">

**Author:** ![gadh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19adc/32.png) [@gadh](https://www.ruby-forum.com/u/gadh)\
**Post date:** [April 14, 2013, 10:22pm UTC](https://www.ruby-forum.com/t/using-upstream-module-that-wont-override-the-original-request/228224/2 "2013-04-14T22:22:04Z")

</div>

Hello!

On Sun, Apr 14, 2013 at 6:22 AM, gadh wrote:

> so how can i achieve my goal ?  
> I don’t understand what you’re saying completely, but you may find the  
> subrequest API provided by ngx\_lua fit your needs:

```
http://wiki.nginx.org/HttpLuaModule#ngx.location.capture

```

And also its cosocket API:

```
http://wiki.nginx.org/HttpLuaModule#ngx.socket.tcp

```

I think you can just write a little Lua to do your task without  
writing your own nginx C module. Well, just a suggestion.

Best regards,  
-agentzh
