How to put rewrite rules for multiple plone instances

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

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;

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

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;
      }

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#proxy_set_header

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

On Fri, Jan 16, 2009 at 9:10 PM, Igor S. [email protected] wrote:

location = / {

Igor S.
Igor Sysoev

Thank you very much Igor,
I have gained some expertise in Nginx :slight_smile:

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

Vishnu

On Sat, Jan 17, 2009 at 12:02:42PM +0530, Vishnu Kumar D R wrote:

is not possible, but this one:


Igor S.
Igor Sysoev

Thank you very much Igor,
I have gained some expertise in Nginx :slight_smile:

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;
      }

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.

Igor,

On Sat, Jan 17, 2009 at 1:38 PM, Igor S. [email protected] 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

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_HOST}:80/$1 [L,P]

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_HOST}:80/$1 [L,P]

location / {
proxy_pass
http://127.0.0.1:8080/VirtualHostBase/http/$host:80$request_uri;
}

Igor S. 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_HOST}:80/$1 [L,P]

location / {
proxy_pass
http://127.0.0.1:8080/VirtualHostBase/http/$host:80$request_uri;
}

Hi Igor,

Then what is it for
RewriteRule ^/(.*)
http://127.0.0.1:8050/VirtualHostBase/http/%{HTTP_HOST}:80/live/automiddleeast/VirtualHostRoot/$1
[L,P]

Thanks
Vishnu

Hi,
Mahiti Support wrote:

Hi Igor,

Then what is it for
RewriteRule ^/(.*)
http://127.0.0.1:8050/VirtualHostBase/http/%{HTTP_HOST}:80/live/automiddleeast/VirtualHostRoot/$1
[L,P]

Thanks
Vishnu

What is the rewrite rule in nginx for the mentioned apache one?

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.

Mahiti Support wrote:

Hi,
Mahiti Support wrote:

Hi Igor,

Then what is it for
RewriteRule ^/(.*)
http://127.0.0.1:8050/VirtualHostBase/http/%{HTTP_HOST}:80/live/automiddleeast/VirtualHostRoot/$1
[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 Re: How to put rewrite rules for multiple plone instances
Then i knew that i was answered twice.
Thanks :slight_smile: