[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nginx
Subject:    conditional proxy_pass
From:       David Woodstuck <leeon2013 () gmail ! com>
Date:       2017-07-20 15:24:44
Message-ID: CAD6THg64C5Vvt2Gq-nU2JKE4d1b8dE+49inXHFrWgQuN8zK1uA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


      I just use Nginx for a couple of weeks. I have the following
questions. I hope I can get your help.

I have a big web application whose urls are dev01.mydomain.com,
dev02.mydomain and dev03.mydomain.com. I like to use Nginx to deliver this
application for its users. On each page, there are a lot of iframes whose
src can be one of dev01.mydomain.com, dev02.mydomain and dev03.mydomain.com.
I like to use following conf to achieve one url for its users:

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;
        #access_log  /var/log/nginx/log/host.access.log  main;

        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;

            proxy_pass http://dev01.mydomain.com/;
            subs_filter 'http://dev02.mydomain.com/(.*)' '
http://dev01.mydomain.com/?http://dev02.mydomain.com/$1';
            subs_filter 'http://dev03.mydomain.com/(.*)' '
http://dev01.mydomain.com/?http://dev03.mydomain.com/$1';
         }
}

My requirements are:
 (1). Request with url - http://www.mydomain.com/?http://... will proxy to
http://dev02.mydomain.com/ or http://dev03.mydomain.com/ depending on a
value after ?
 (2). Other request will proxy to http://dev01.mydomain.com/.

How do I achieve these requirements?

Thanks,

David

[Attachment #5 (text/html)]

<div dir="ltr"><div style="font-size:13.3333339691162px"><br></div><div \
style="font-size:13.3333339691162px">         I just use Nginx for a couple of weeks. \
I have the following questions. I hope I can get your help.</div><div \
style="font-size:13.3333339691162px"><br></div><div \
style="font-size:13.3333339691162px">I have a big web application whose urls are  <a \
href="http://dev01.mydomain.com/" target="_blank">dev01.mydomain.com</a>, \
dev02.mydomain and  <a href="http://dev03.mydomain.com/" \
target="_blank">dev03.mydomain.com</a>. I like to use Nginx to deliver this \
application for its users. On each page, there are a lot of iframes whose src can be \
one of  <a href="http://dev01.mydomain.com/" target="_blank">dev01.mydomain.com</a>, \
dev02.mydomain and  <a href="http://dev03.mydomain.com/" \
target="_blank">dev03.mydomain.com</a>. I like to use following conf to achieve one \
url for its users:</div><div style="font-size:13.3333339691162px"><br></div><div \
style="font-size:13.3333339691162px"><div>server {</div><div>            listen       \
80;</div><div>            server_name   localhost;</div><div><br></div><div>          \
#charset koi8-r;</div><div>            #access_log   \
/var/log/nginx/log/host.<wbr>access.log   main;</div><div><br></div><div>            \
location / {</div><div>                  root    /usr/share/nginx/html;</div><div>    \
index   index.html index.htm;</div><div><br></div><div>                  proxy_pass  \
<a href="http://dev01.mydomain.com/" \
target="_blank">http://dev01.mydomain.com/</a>;</div><div>                  \
subs_filter &#39;<a href="http://dev02.mydomain.com/(.*)" \
target="_blank">http://dev02.mydomain.com/(.*<wbr>)</a>&#39; &#39;<a \
href="http://dev01.mydomain.com/?http://dev02.mydomain.com/$1" \
target="_blank">http://dev01.mydomain.com/?<wbr>http://dev02.mydomain.com/$1</a>&#39;;</div></div><div \
style="font-size:13.3333339691162px">                  subs_filter &#39;<a \
href="http://dev03.mydomain.com/(.*)" \
target="_blank">http://dev03.mydomain.com/(.*<wbr>)</a>&#39; &#39;<a \
href="http://dev01.mydomain.com/?http://dev03.mydomain.com/$1" \
target="_blank">http://dev01.mydomain.com/?<wbr>http://dev03.mydomain.com/$1</a>&#39;;</div><div \
style="font-size:13.3333339691162px">              }</div><div \
style="font-size:13.3333339691162px">}</div><div \
style="font-size:13.3333339691162px"><br></div><div \
style="font-size:13.3333339691162px">My requirements are:</div><div \
style="font-size:13.3333339691162px">  (1). Request with url -  <a \
href="http://www.mydomain.com/?http://." \
target="_blank">http://www.mydomain.com/?http:<wbr>//.</a>.. will proxy to  <a \
href="http://dev02.mydomain.com/" target="_blank">http://dev02.mydomain.com/</a>  or  \
<a href="http://dev03.mydomain.com/" target="_blank">http://dev03.mydomain.com/</a>  \
depending on a value after ?</div><div style="font-size:13.3333339691162px">  (2). \
Other request will proxy to  <a href="http://dev01.mydomain.com/" \
target="_blank">http://dev01.mydomain.com/</a>.</div><div \
style="font-size:13.3333339691162px"><br></div><div \
style="font-size:13.3333339691162px">How do I achieve these requirements?</div><div \
style="font-size:13.3333339691162px"><br></div><div \
style="font-size:13.3333339691162px">Thanks,</div><div \
style="font-size:13.3333339691162px"><br></div><div \
style="font-size:13.3333339691162px">David</div></div>



_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic