Forum: NGINX How to put rewrite rules for multiple plone instances

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Afd467b5dc52d3e549e80ffaffb65c36?d=identicon&s=25 Vishnu Kumar D R (Guest)
on 2009-01-16 08:35
(Received via mailing list)
Hi,

I am having some 10 Plone sites running on a Zope instance in port 8002.
I have configured it to run behind varnish port 6081.

now, my nginx configuration is

 server {
        listen       80;
        server_name server03.example.in;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        location = / {
           rewrite (.*) / last;
       }

       location / {
           proxy_pass http://localhost:6081;
           include /usr/local/nginx/includes/proxy.conf;
       }

Is this right for the specified config?
Cause its not working
(Actually when we give our http://localhost:8002, It opens up the main
page,
from there requests all handled for each site)

Thanks
Vishnu, Bangalore
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-01-16 08:58
(Received via mailing list)
On Fri, Jan 16, 2009 at 12:58:15PM +0530, Vishnu Kumar D R wrote:

>
>         #charset koi8-r;
>
>         #access_log  logs/host.access.log  main;

This is a cycle.

>         location = / {
>            rewrite (.*) / last;
>        }

What do you intend by this ?

>        location / {
>            proxy_pass http://localhost:6081;

+            proxy_set  Host  $host;
Afd467b5dc52d3e549e80ffaffb65c36?d=identicon&s=25 Vishnu Kumar D R (Guest)
on 2009-01-17 05:58
(Received via mailing list)
Hi Igor,

Actually, I have this working config( it has only one plone site in
/live/SBO)

  server {
        listen       80;
        server_name  w01.xxxxxxx.com;

        access_log  logs/plone.access.log  main;
        location = / {
            rewrite (.*) /live/SBO last;
        }

        location / {
            proxy_pass http://localhost:6081;
            include /usr/local/nginx/includes/proxy.conf;
        }
    }
But, in the server mentioned below, all the plone sites exist in "/".
Thats what i did.
Suggestions?

> >
> What do you intend by this ?
>
> >        location / {
> >            proxy_pass http://localhost:6081;
>
> +            proxy_set  Host  $host;

Is this complusory?
What it does?

>  >            include /usr/local/nginx/includes/proxy.conf;
> >        }
> >
> > Is this right for the specified config?
> > Cause its not working
> > (Actually when we give our http://localhost:8002, It opens up the main
> page,
> > from there requests all handled for each site)
>

Thanks
Vishnu
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-01-17 06:26
(Received via mailing list)
On Fri, Jan 16, 2009 at 05:18:25PM +0530, Vishnu Kumar D R wrote:

>         location = / {
> Suggestions?
Then you do not need this location:

         location = / {
            rewrite (.*) / last;
        }

at all.

> > >
> > What do you intend by this ?
> >
> > >        location / {
> > >            proxy_pass http://localhost:6081;
> >
> > +            proxy_set  Host  $host;
>
> Is this complusory?

Yes.

-            proxy_set         Host  $host;
+            proxy_set_header  Host  $host;

> What it does?

http://wiki.codemongers.com/NginxHttpProxyModule#p...
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-01-17 08:12
(Received via mailing list)
On Fri, Jan 16, 2009 at 05:18:25PM +0530, Vishnu Kumar D R wrote:

>         location = / {
>             rewrite (.*) /live/SBO last;
>         }

BTW, it's better to use just:

          location = / {
              proxy_pass http://localhost:6081/live/SBO;
              include /usr/local/nginx/includes/proxy.conf;
          }
Afd467b5dc52d3e549e80ffaffb65c36?d=identicon&s=25 Vishnu Kumar D R (Guest)
on 2009-01-17 09:39
(Received via mailing list)
Thanks Igor,

Its working

> I look like a fool now.
Anyway, is this rewrite possible( for two domains server03.example.com
and
klk.example.com)

if ($host ~* klk\.example\.com$) {
                location = / {
                    rewrite (.*) /Kolkata last;
                }
        }
location / {
            proxy_pass http://localhost:6081;
            include /usr/local/nginx/includes/proxy.conf;
        }

Meaning that for server03 no rewrite and for klk rewrite to /Kolkata
(since both domains are in same zope instance running behind varnish)
Or do i have to create separate server config for both domains


Thanks
Vishnu
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-01-17 09:53
(Received via mailing list)
On Fri, Jan 16, 2009 at 08:55:47PM +0530, Vishnu Kumar D R wrote:

> >        }
>                     rewrite (.*) /Kolkata last;
>                 }
>         }
> location / {
>             proxy_pass http://localhost:6081;
>             include /usr/local/nginx/includes/proxy.conf;
>         }
>
> Meaning that for server03 no rewrite and for klk rewrite to /Kolkata
> (since both domains are in same zope instance running behind varnish)
> Or do i have to create separate server config for both domains

This rewrite:

     if ($host ~* klk\.example\.com$) {
          location = / {
             rewrite (.*) /Kolkata last;
         }
     }

is not possible, but this one:

     location = / {
         if ($host ~* klk\.example\.com$) {
             rewrite (.*) /Kolkata last;
         }
     }

is possible. However, it's much better to create separate server for
every
non-generic server, then to write a lot of if/rewrite's.
Af5d5c05abdfc0cde3e2a485917fb92a?d=identicon&s=25 Vishnu Kumar D R (Guest)
on 2009-01-17 10:25
(Received via mailing list)
On Fri, Jan 16, 2009 at 9:10 PM, Igor Sysoev <is@rambler-co.ru> wrote:

>     location = / {
> Igor Sysoev
> http://sysoev.ru/en/
>
>
Thank you very much Igor,
I have gained some expertise in Nginx :)

Also, How do we make rewrite invisible to viewers, cause the rewrite is
visible for every link in the site klk.example.com.

Vishnu
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-01-17 11:28
(Received via mailing list)
On Sat, Jan 17, 2009 at 12:02:42PM +0530, Vishnu Kumar D R wrote:

> > is not possible, but this one:
> >
> > --
> > Igor Sysoev
> > http://sysoev.ru/en/
> >
> >
> Thank you very much Igor,
> I have gained some expertise in Nginx :)
>
> Also, How do we make rewrite invisible to viewers, cause the rewrite is
> visible for every link in the site klk.example.com.

These rewrite's are internal and invisible for client.
However, it's better to use just:

          location = / {
              proxy_pass http://localhost:6081/Kolkata;
              include /usr/local/nginx/includes/proxy.conf;
          }
Af5d5c05abdfc0cde3e2a485917fb92a?d=identicon&s=25 Vishnu Kumar D R (Guest)
on 2009-01-22 06:02
(Received via mailing list)
Igor,

On Sat, Jan 17, 2009 at 1:38 PM, Igor Sysoev <is@rambler-co.ru> wrote:

>
>
I am getting a error when i edited as you had said above

2009/01/21 20:38:07 [emerg] 15886#0: "proxy_pass" may not have URI part
in
location given by regular expression, or inside named location, or
inside
the "if" statement, or inside the "limit_except" block in
/usr/local/nginx/vhosts/server03.conf:9

The server03.conf exists like this

        7         location = / {
      8                 if ($host ~* klk\.explocity\.com$) {
      9                         proxy_pass
http://localhost:6081/Kolkata;
     10                         include
/usr/local/nginx/includes/proxy.conf;
     11                 }

Please advice
Also, i have hosted this klk.explocity.com using the rewrite(.*)
If you have a look at the site, it shows the /Kolkata in all.
Technically speaking, its not an ideal rewrite, right?

Vishnu
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-01-22 07:23
(Received via mailing list)
On Thu, Jan 22, 2009 at 10:21:06AM +0530, Vishnu Kumar D R wrote:

> > > visible for every link in the site klk.example.com.
> > --
>
> Also, i have hosted this klk.explocity.com using the rewrite(.*)
> If you have a look at the site, it shows the /Kolkata in all.
> Technically speaking, its not an ideal rewrite, right?

If you ever try to write

     server {
        server_name  default.explocity.com klk.explocity.com;

        location = / {
            if ($host ~* klk\.explocity\.com$ {
                ...
            }
        }
    }

This means that you should use

    server {
        server_name  default.explocity.com;

        location = / {
            ...
        }

    }

    server {
        server_name klk.explocity.com;

        location = / {
            ...
        }
    }

Do not mix server and locations.
A request should be routed first by server, then by location.
Af5d5c05abdfc0cde3e2a485917fb92a?d=identicon&s=25 Vishnu Kumar D R (Guest)
on 2009-01-28 11:34
(Received via mailing list)
Hi Igor,

Let me make it to the point

whats the nginx equivalent for the statement in apache2?
RewriteRule ^/(.*)
http://localhost:8080/VirtualHostBase/http/%{HTTP_... [L,P]
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-01-28 11:42
(Received via mailing list)
On Wed, Jan 28, 2009 at 03:56:53PM +0530, Vishnu Kumar D R wrote:

> Hi Igor,
>
> Let me make it to the point
>
> whats the nginx equivalent for the statement in apache2?
> RewriteRule ^/(.*)
> http://localhost:8080/VirtualHostBase/http/%{HTTP_... [L,P]

location / {
    proxy_pass
http://127.0.0.1:8080/VirtualHostBase/http/$host:8...
}
Af5d5c05abdfc0cde3e2a485917fb92a?d=identicon&s=25 Mahiti Support (mahiti)
on 2009-07-01 14:18
Igor Sysoev wrote:
> On Wed, Jan 28, 2009 at 03:56:53PM +0530, Vishnu Kumar D R wrote:
>
>> Hi Igor,
>>
>> Let me make it to the point
>>
>> whats the nginx equivalent for the statement in apache2?
>> RewriteRule ^/(.*)
>> http://localhost:8080/VirtualHostBase/http/%{HTTP_... [L,P]
>
> location / {
>     proxy_pass
> http://127.0.0.1:8080/VirtualHostBase/http/$host:8...
> }

Hi Igor,

Then what is it for
RewriteRule ^/(.*)
http://127.0.0.1:8050/VirtualHostBase/http/%{HTTP_...
[L,P]

Thanks
Vishnu
Af5d5c05abdfc0cde3e2a485917fb92a?d=identicon&s=25 Mahiti Support (mahiti)
on 2009-07-31 09:55
Hi,
Mahiti Support wrote:
>
> Hi Igor,
>
> Then what is it for
> RewriteRule ^/(.*)
> 
http://127.0.0.1:8050/VirtualHostBase/http/%{HTTP_...
> [L,P]
>
> Thanks
> Vishnu

What is the rewrite rule in nginx for the mentioned apache one?
Af5d5c05abdfc0cde3e2a485917fb92a?d=identicon&s=25 Mahiti Support (mahiti)
on 2009-07-31 15:22
Mahiti Support wrote:
> Hi,
> Mahiti Support wrote:
>>
>> Hi Igor,
>>
>> Then what is it for
>> RewriteRule ^/(.*)
>> 
http://127.0.0.1:8050/VirtualHostBase/http/%{HTTP_...
>> [L,P]
>>
>> Thanks
>> Vishnu
>
> What is the rewrite rule in nginx for the mentioned apache one?

Sorry man, but i didnt get your reply through the Nginx Ruby Forum, so i
posted again,
but when i saw it in here http://forum.nginx.org/read.php?2,3590
Then i knew that i was answered twice.
Thanks :)
This topic is locked and can not be replied to.