Welcome! Log In Create A New Profile

Advanced

Re: nginx rewrite help

June 18, 2009 11:16AM
On Thu, Jun 18, 2009 at 08:10:27AM -0700, Kevin Castiglione wrote:

> 2009/6/18 Igor Sysoev <is@rambler-co.ru>
>
> > On Thu, Jun 18, 2009 at 07:44:55AM -0700, Kevin Castiglione wrote:
> >
> > > 2009/6/18 Igor Sysoev <is@rambler-co.ru>
> > >
> > > > On Thu, Jun 18, 2009 at 07:21:33AM -0700, Kevin Castiglione wrote:
> > > >
> > > > > 2009/6/18 Igor Sysoev <is@rambler-co.ru>
> > > > >
> > > > > > On Thu, Jun 18, 2009 at 06:38:54AM -0700, Kevin Castiglione wrote:
> > > > > >
> > > > > > > 2009/6/18 Igor Sysoev <is@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.

> also instead of $host, if i want to use domain or subdomain can you tell how
> i can extract: [aa.bb.com]
> -> domain - bb.com
> -> subdomain - aa

server {
server_name ~^([^.])\.(.+)$)$;

set $subdomain $1;
set $domain $2;

location / {
fastcgi_param SCRIPT_FILENAME /$domain$fastcgi_script_name;


> > Also, this
> >
> > if ($http_x_forwarded_for ~ "(?:^|,)\s*(\d+\.\d+\.\d+\.\d+)\s*$") {
> > set $addr $1;
> > }
> >
> > fastcgi_param REMOTE_ADDR $addr;
> >
> > means that anyone may forge his address.
>
> without this my web app gets client ip address as the ip address of the
> machine running nginx and not the actual client.

fastcgi_param REMOTE_ADDR $remote_addr;

sets address of nginx's client.


--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

nginx rewrite help

Kevin Castiglione June 18, 2009 12:22AM

Re: nginx rewrite help

edogawaconan June 18, 2009 12:42AM

Re: nginx rewrite help

edogawaconan June 18, 2009 12:46AM

Re: nginx rewrite help

edogawaconan June 18, 2009 12:49AM

Re: nginx rewrite help

edogawaconan June 18, 2009 01:09AM

Re: nginx rewrite help

Kevin Castiglione June 18, 2009 09:37AM

Re: nginx rewrite help

Igor Sysoev June 18, 2009 03:43AM

Re: nginx rewrite help

Kevin Castiglione June 18, 2009 09:38AM

Re: nginx rewrite help

Igor Sysoev June 18, 2009 09:49AM

Re: nginx rewrite help

Kevin Castiglione June 18, 2009 10:21AM

Re: nginx rewrite help

Igor Sysoev June 18, 2009 10:22AM

Re: nginx rewrite help

Kevin Castiglione June 18, 2009 10:44AM

Re: nginx rewrite help

Igor Sysoev June 18, 2009 10:51AM

Re: nginx rewrite help

Kevin Castiglione June 18, 2009 11:10AM

Re: nginx rewrite help

Igor Sysoev June 18, 2009 11:16AM

Re: nginx rewrite help

Kevin Castiglione June 18, 2009 08:26PM

Re: nginx rewrite help

edogawaconan June 18, 2009 11:55PM

Re: nginx rewrite help

Kevin Castiglione June 19, 2009 01:18AM

Re: nginx rewrite help

edogawaconan June 19, 2009 02:06AM

Re: nginx rewrite help

Kevin Castiglione June 19, 2009 08:53AM

Re: nginx rewrite help

Igor Sysoev June 19, 2009 02:12AM

Re: nginx rewrite help

Kevin Castiglione June 19, 2009 08:54AM

Re: nginx rewrite help

Igor Sysoev June 19, 2009 08:58AM

Re: nginx rewrite help

Kevin Castiglione June 19, 2009 10:28AM

Re: nginx rewrite help

Igor Sysoev June 19, 2009 10:43AM

Re: nginx rewrite help

Kevin Castiglione June 19, 2009 10:56AM

Re: nginx rewrite help

edogawaconan June 19, 2009 10:48AM

Re: nginx rewrite help

Kevin Castiglione June 19, 2009 10:59AM

Re: nginx rewrite help

Igor Sysoev June 19, 2009 11:13AM

Re: nginx rewrite help

Kevin Castiglione June 19, 2009 09:02PM

Re: nginx rewrite help

edogawaconan June 18, 2009 11:23AM

Re: nginx rewrite help

Kevin Castiglione June 18, 2009 08:26PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 303
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready