# X-forwarded-for and two nginx instances + apache

**URL:** <https://www.ruby-forum.com/t/x-forwarded-for-and-two-nginx-instances-apache/208260>\
**Category:** NGINX\
**Created:** [June 13, 2011, 5:10pm UTC](https://www.ruby-forum.com/t/x-forwarded-for-and-two-nginx-instances-apache/208260 "2011-06-13T17:10:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [June 13, 2011, 5:10pm UTC](https://www.ruby-forum.com/t/x-forwarded-for-and-two-nginx-instances-apache/208260/1 "2011-06-13T17:10:50Z")

</div>

Hi there,

I’m running two nginx instances in-front of Apache. Trying to pass  
visitors real-ip address to apache.

In normal cases (with one nginx instance in-front of Apache) I’m using:

```
        proxy_set_header X-Forwarded-For 

```

$proxy\_add\_x\_forwarded\_for;

and mod\_rpaf on apache to handle the X-Forwarded-For header.

How do I proceed with two nginx instances where the first one should  
pass $remote\_addr to the second one, which should pass it to Apache?

Thanks!

Boyko

---

<div class="post-metadata">

**Author:** ![Boyko\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@Boyko\_Y](https://www.ruby-forum.com/u/Boyko_Y)\
**Post date:** [June 14, 2011, 10:22am UTC](https://www.ruby-forum.com/t/x-forwarded-for-and-two-nginx-instances-apache/208260/2 "2011-06-14T10:22:43Z")

</div>

Solved! I was (wrongly) overwriting the x-real-ip and x-forwarded-for  
headers with the second nginx.

Boyko
