2009/6/18 Igor Sysoev <span dir="ltr">&lt;<a href="mailto:is@rambler-co.ru">is@rambler-co.ru</a>&gt;</span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">On Thu, Jun 18, 2009 at 07:44:55AM -0700, Kevin Castiglione wrote:<br>
<br>
&gt; 2009/6/18 Igor Sysoev &lt;<a href="mailto:is@rambler-co.ru">is@rambler-co.ru</a>&gt;<br>
&gt;<br>
&gt; &gt; On Thu, Jun 18, 2009 at 07:21:33AM -0700, Kevin Castiglione wrote:<br>
&gt; &gt;<br>
&gt; &gt; &gt; 2009/6/18 Igor Sysoev &lt;<a href="mailto:is@rambler-co.ru">is@rambler-co.ru</a>&gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; On Thu, Jun 18, 2009 at 06:38:54AM -0700, Kevin Castiglione wrote:<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; 2009/6/18 Igor Sysoev &lt;<a href="mailto:is@rambler-co.ru">is@rambler-co.ru</a>&gt;<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; On Wed, Jun 17, 2009 at 09:22:46PM -0700, Kevin Castiglione wrote:<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; hei guys<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; i want all urls to be re-written as follows:<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; xx /host/xx<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; xx is the url full path, it should be written as /domain/xx where<br>
&gt; &gt; &gt; &gt; host is<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; the hostname.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; for example <a href="http://www.ABCD.COM" target="_blank">www.ABCD.COM</a> &lt;<a href="http://www.abcd.com/" target="_blank">http://www.abcd.com/</a>&gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; /test?1 ---&gt; /<a href="http://ABCD.COM/test?1" target="_blank">ABCD.COM/test?1</a> &lt;<a href="http://abcd.com/test?1" target="_blank">http://abcd.com/test?1</a>&gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; is it possible to do this with nginx?<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; thank you!<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; Should it be redirect or what ?<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; i dont want it to be a permanent redirect. i just want the url to be<br>
&gt; &gt; &gt; &gt; &gt; rewritten for application processing. i want different domains to be<br>
&gt; &gt; &gt; &gt; handled<br>
&gt; &gt; &gt; &gt; &gt; by same web app an dmy webframe work supports only url-level<br>
&gt; &gt; application<br>
&gt; &gt; &gt; &gt; &gt; mapping. that is why i need this rewrite.<br>
&gt; &gt; &gt; &gt; &gt; thank you<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; If you use proxing, then<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; server {<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;   location / {<br>
&gt; &gt; &gt; &gt;       proxy_pass  <a href="http://backend/$host$request_uri" target="_blank">http://backend/$host$request_uri</a>;<br>
&gt; &gt; &gt; &gt;    }<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; }<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; im using fastcgi backend.<br>
&gt; &gt;<br>
&gt; &gt; Then<br>
&gt; &gt;<br>
&gt; &gt;   location / {<br>
&gt; &gt;       ...<br>
&gt; &gt;       fastcgi_param  SCRIPT_FILENAME<br>
&gt; &gt;                      /path/to/scripts/$host$fastcgi_script_name;<br>
&gt; &gt;       ...<br>
&gt; &gt;    }<br>
&gt; &gt;<br>
&gt; igor:<br>
&gt; does this mean the backend fastcgi processes have to be in the same machine?<br>
&gt; i have my backends running on different machine like this<br>
<br>
</div></div>No, this path<br>
<div class="im">       /path/to/scripts/$host$fastcgi_script_name;<br>
</div>may be on any host.<br>
<br>
In your case you need probably this:<br>
<br>
      fastcgi_param SCRIPT_FILENAME /$host$fastcgi_script_name;</blockquote><div>so with this i dont need to write any rewrite rule?<br><br>also instead of $host, if i want to use domain or subdomain can you tell how i can extract: [<a href="http://aa.bb.com">aa.bb.com</a>]<br>
-&gt; domain - <a href="http://bb.com">bb.com</a><br>-&gt; subdomain - aa<br><br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Also, this<br>
<div class="im"><br>
       if ($http_x_forwarded_for ~ &quot;(?:^|,)\s*(\d+\.\d+\.\d+\.\d+)\s*$&quot;) {<br>
           set  $addr  $1;<br>
       }<br>
<br>
</div>       fastcgi_param REMOTE_ADDR     $addr;<br>
<br>
means that anyone may forge his address.</blockquote>without this my web app gets client ip address as the ip address of the machine running nginx and not the actual client.<br><br></div><br>