# Get Selected backend info

**URL:** <https://www.ruby-forum.com/t/get-selected-backend-info/231849>\
**Category:** NGINX\
**Created:** [September 2, 2014, 9:51pm UTC](https://www.ruby-forum.com/t/get-selected-backend-info/231849 "2014-09-02T21:51:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [September 2, 2014, 9:51pm UTC](https://www.ruby-forum.com/t/get-selected-backend-info/231849/1 "2014-09-02T21:51:47Z")

</div>

Hello,

I couldn’t find much information other than this thread  
[http://mailman.nginx.org/pipermail/nginx/2008-February/003550.html](http://mailman.nginx.org/pipermail/nginx/2008-February/003550.html)  
which  
is a dead-end.

I would like to add the selected backend/upstream to an “X-Backend”  
header  
before dispatching the request to the backend.

In Varnish I can do this via:  
set req.http.X-Backend = req.backend

In HAProxy I can do this via:  
http-send-name-header X-Backend

However, I am stumped with Nginx. I imagine I could work around it by  
redirecting to the same server or some other trickery (not sure if  
that’s a  
reasonable approach–what would the config look like in any case here?).

Any other tips or suggestion are welcome.

Thanks,  
Aleem

---

<div class="post-metadata">

**Author:** ![Aleem\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8491ac/32.png) [@Aleem\_B](https://www.ruby-forum.com/u/Aleem_B)\
**Post date:** [September 2, 2014, 9:56pm UTC](https://www.ruby-forum.com/t/get-selected-backend-info/231849/2 "2014-09-02T21:56:03Z")

</div>

Hello!

On Wed, Sep 03, 2014 at 12:50:27AM +0500, Aleem B wrote:

> Hello,
> 
> I couldn’t find much information other than this thread  
> [http://mailman.nginx.org/pipermail/nginx/2008-February/003550.html](http://mailman.nginx.org/pipermail/nginx/2008-February/003550.html) which  
> is a dead-end.
> 
> I would like to add the selected backend/upstream to an “X-Backend” header  
> before dispatching the request to the backend.

You can’t. The request is created _before_ the backend server  
will be selected (and the same request may be sent to more than  
one backend server due to proxy\_next\_upstream).

–  
Maxim D.

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