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 05:26:02PM -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 08:10:27AM -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 07:44:55AM -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 Thu, Jun 18, 2009 at 07:21:33AM -0700, Kevin Castiglione wrote:<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &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; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; On Thu, Jun 18, 2009 at 06:38:54AM -0700, Kevin Castiglione<br>
&gt; &gt; wrote:<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &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; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; On Wed, Jun 17, 2009 at 09:22:46PM -0700, Kevin Castiglione<br>
&gt; &gt; &gt; &gt; wrote:<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; hei guys<br>
&gt; &gt; &gt; &gt; &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; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; xx /host/xx<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; xx is the url full path, it should be written as<br>
&gt; &gt; /domain/xx<br>
&gt; &gt; &gt; &gt; where<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; host is<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; the hostname.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &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; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &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; &gt; &gt; &gt; &gt; is it possible to do this with nginx?<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; thank you!<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Should it be redirect or what ?<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; i dont want it to be a permanent redirect. i just want the<br>
&gt; &gt; url to<br>
&gt; &gt; &gt; &gt; be<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; rewritten for application processing. i want different<br>
&gt; &gt; domains to<br>
&gt; &gt; &gt; &gt; be<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; handled<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; by same web app an dmy webframe work supports only url-level<br>
&gt; &gt; &gt; &gt; &gt; &gt; application<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; mapping. that is why i need this rewrite.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; thank you<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; If you use proxing, then<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; server {<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;   location / {<br>
&gt; &gt; &gt; &gt; &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; &gt; &gt; &gt; &gt;    }<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; }<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; im using fastcgi backend.<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; Then<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt;   location / {<br>
&gt; &gt; &gt; &gt; &gt; &gt;       ...<br>
&gt; &gt; &gt; &gt; &gt; &gt;       fastcgi_param  SCRIPT_FILENAME<br>
&gt; &gt; &gt; &gt; &gt; &gt;                      /path/to/scripts/$host$fastcgi_script_name;<br>
&gt; &gt; &gt; &gt; &gt; &gt;       ...<br>
&gt; &gt; &gt; &gt; &gt; &gt;    }<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; igor:<br>
&gt; &gt; &gt; &gt; &gt; does this mean the backend fastcgi processes have to be in the same<br>
&gt; &gt; &gt; &gt; machine?<br>
&gt; &gt; &gt; &gt; &gt; i have my backends running on different machine like this<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; No, this path<br>
&gt; &gt; &gt; &gt;        /path/to/scripts/$host$fastcgi_script_name;<br>
&gt; &gt; &gt; &gt; may be on any host.<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; In your case you need probably this:<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;      fastcgi_param SCRIPT_FILENAME /$host$fastcgi_script_name;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; so with this i dont need to write any rewrite rule?<br>
&gt; &gt;<br>
&gt; &gt; Yes.<br>
&gt; &gt;<br>
&gt; igor,<br>
&gt; i changed this and tried. it does not have any affect on the url mapping. my<br>
&gt; fastcgi backend still gets the same url as before.<br>
&gt; this is what i see, with the change you had given.<br>
&gt; <a href="http://xx.com/yy" target="_blank">xx.com/yy</a> ---&gt; <a href="http://xx.com/yy" target="_blank">xx.com/yy</a><br>
&gt;<br>
&gt; while this is what i want on the webapp/fastcgi backend<br>
&gt; <a href="http://xx.com/yy" target="_blank">xx.com/yy</a> --&gt; <a href="http://xx.com/xx.com/yy" target="_blank">xx.com/xx.com/yy</a><br>
&gt; im pasting my full config here:<br>
&gt;<br>
&gt; #user  nobody;<br>
&gt; worker_processes  1;<br>
&gt;<br>
&gt; error_log  /home/app/error_all.log;<br>
&gt; pid        /home/app/nginx.pid;<br>
&gt;<br>
&gt; events {<br>
&gt;     worker_connections  1024;<br>
&gt; }<br>
&gt;<br>
&gt; http {<br>
&gt;     include       mime.types;<br>
&gt;     default_type  application/octet-stream;<br>
&gt;     client_header_buffer_size   8k;<br>
&gt;     large_client_header_buffers  4  8k;<br>
&gt;     fastcgi_buffers      32 4k;<br>
&gt;     fastcgi_buffer_size  4k;<br>
&gt;     sendfile        on;<br>
&gt;<br>
&gt;     server_names_hash_bucket_size 64;<br>
&gt;     keepalive_timeout  5;<br>
&gt;<br>
&gt;     gzip  on;<br>
&gt;     gzip_comp_level  1;<br>
&gt;     gzip_proxied     private;<br>
&gt;     gzip_buffers     8 4k;<br>
&gt;<br>
&gt;<br>
&gt;     upstream backend_flock{<br>
&gt;         server <a href="http://app1.XXX.com:8492" target="_blank">app1.XXX.com:8492</a> fail_timeout=1s;<br>
&gt;     }<br>
&gt;     server {<br>
&gt;         listen 8080;<br>
&gt;         access_log   /home/app/access_flock.log;<br>
&gt;<br>
&gt;         client_max_body_size 10m;<br>
&gt;<br>
&gt;         location /static {<br>
&gt;             root   /home/app/work/flock;<br>
&gt;         }<br>
&gt;         location / {<br>
&gt;             root   /home/app/work/flock;<br>
&gt;<br>
&gt;             fastcgi_pass backend_flock;<br>
&gt;<br>
&gt;             fastcgi_param SCRIPT_FILENAME /$host$fastcgi_script_name;<br>
&gt;             fastcgi_param PATH_INFO       $fastcgi_script_name;<br>
&gt;             fastcgi_param QUERY_STRING    $query_string;<br>
&gt;             fastcgi_param CONTENT_TYPE    $content_type;<br>
&gt;             fastcgi_param CONTENT_LENGTH  $content_length;<br>
&gt;             fastcgi_param REQUEST_METHOD  $request_method;<br>
&gt;             fastcgi_param REMOTE_ADDR     $remote_addr;<br>
&gt;             fastcgi_param REMOTE_PORT     $remote_port;<br>
&gt;             fastcgi_param SERVER_PROTOCOL $server_protocol;<br>
&gt;             fastcgi_param SERVER_ADDR     $server_addr;<br>
&gt;             fastcgi_param SERVER_PORT     $server_port;<br>
&gt;             fastcgi_param SERVER_NAME     $server_name;<br>
&gt;<br>
&gt;         }<br>
&gt;<br>
&gt;     }<br>
&gt; }<br>
<br>
</div></div>Probably, you need<br>
<br>
 fastcgi_param SCRIPT_FILENAME /home/app/work/flock/$host$fastcgi_script_name;<br>
<br>
 or<br>
<br>
 fastcgi_param SCRIPT_FILENAME $document_root/$host$fastcgi_script_name;<br>
</blockquote><div>tried these with no results igor!<br>thanks <br></div></div><br>