# Proxy\_pass destination set by request custom header

**URL:** <https://www.ruby-forum.com/t/proxy-pass-destination-set-by-request-custom-header/220834>\
**Category:** NGINX\
**Created:** [June 21, 2012, 7:07pm UTC](https://www.ruby-forum.com/t/proxy-pass-destination-set-by-request-custom-header/220834 "2012-06-21T19:07:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 21, 2012, 7:07pm UTC](https://www.ruby-forum.com/t/proxy-pass-destination-set-by-request-custom-header/220834/1 "2012-06-21T19:07:06Z")

</div>

Hello,

location ~ ^/api/v(\d)/foo/bar/(.\*) {  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header Host $http\_host;  
proxy\_redirect off;  
proxy\_max\_temp\_file\_size 0;  
proxy\_pass  
http://$http\_x\_destination\_host:$http\_x\_destination\_port/$uri;  
}

What I’m looking for is to have X-Destination-Host and  
X-Destination-Port contaning the exact host where to proxy\_pass.  
Since currently it doesn’t seem to get picked up I would like to ask if  
is this appear correct (not counting security implications).

Thanks.

Posted at Nginx Forum:

> **[proxy\_pass destination set by request custom header](https://forum.nginx.org/read.php?2,227781,227781#msg-227781)**
>
> Hello, location ~ ^/api/v(\\d)/foo/bar/(.\*) { proxy\_set\_header X-Real-IP $remote\_addr; proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for; proxy\_set\_header Host $http\_host; proxy\_redirect off; proxy\_max\_temp\_file\_size
