Forum: NGINX Condition in location for proxy_pass

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
79c330896eea5cf1233c35ea19f2cbd6?d=identicon&s=25 trm asn (Guest)
on 2012-10-16 18:56
(Received via mailing list)
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...

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;
            ----------

            ----------
                proxy_pass         http://10.20.137.21;
                }
79c330896eea5cf1233c35ea19f2cbd6?d=identicon&s=25 trm asn (Guest)
on 2012-10-16 19:01
(Received via mailing list)
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...

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;
                }
               else {
                        return 403;
               }
         ------------
         }

Is that possible achieve inside "location" for "proxy_pass" .

--trm
This topic is locked and can not be replied to.