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