# Condition in location for proxy\_pass

**URL:** <https://www.ruby-forum.com/t/condition-in-location-for-proxy-pass/223774>\
**Category:** NGINX\
**Created:** [October 17, 2012, 11:46am UTC](https://www.ruby-forum.com/t/condition-in-location-for-proxy-pass/223774 "2012-10-17T11:46:57Z")\
**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:** [October 17, 2012, 11:46am UTC](https://www.ruby-forum.com/t/condition-in-location-for-proxy-pass/223774/1 "2012-10-17T11:46:57Z")

</div>

Dear List ,

I need to do a conditional proxy\_pass , but it’s not happening as  
expected  
.

like

set $target  
[http://www.example.com/sso/url.ping?TargetUrl=http://www.example.com/home](http://www.example.com/sso/url.ping?TargetUrl=http://www.example.com/home)

And that $target , I would like to check with $request\_uri in below  
segment  
.

location /sso/ {  
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;  
----------  
if ($target ~ $request\_uri) {  
proxy\_pass [http://10.20.137.21](http://10.20.137.21);  
}  
else {  
return 403;  
}  
------------  
}

Is that possible achieve inside “location” for “proxy\_pass” .
