Personal tools
You are here: Home Storage Nginx as reverse proxy for Zope / Plone + multiple virtual hosts

Nginx as reverse proxy for Zope / Plone + multiple virtual hosts

Posted by Rafal Zawadzki at Jul 01, 2010 02:15 PM |

simply advice how to configure nginx along with multiple domains for Zope instance

There are few ways to configure in Nginx reverse proxy with virtual hosts for Plone's instance. Up to today I was using simply standard Virtual Host Monster:
location / {
  proxy_pass        http://localhost:9080/VirtualHostBase/http/example.com:80/site/VirtualHostRoot/;
  proxy_set_header  X-Real-IP  $remote_addr;
}

which works perfectly, as long your Zope instance is visibly only under one specific (example.com in this case) domain.

Today we were performing migration from old domain to the new domain. Because dns changes have to propagate, configuration should be prepared for handling more than one domain. So, I had few options:

  • use $http_host or $host variable and put it instead of example.com
  • create separate server entries for every virtual host

Second solutions was DRY (do repeat yourself), so I  started playing with variables. I was so surprised, when I noticed that these variables are not working in the proxy_pass context.

So I read again proper Nginx documentation page http://wiki.nginx.org/NginxHttpProxyModule#proxy_pass and realized, that there is special annotation about passing variables in proxy along with example for Zope.

Now, after changes our config file looks like:

location / {
rewrite ^(.*)$ /VirtualHostBase/http/$http_host:80/site/VirtualHostRoot$1 break;
proxy_pass   http://127.0.0.1:9080;
proxy_set_header  X-Real-IP  $remote_addr;
}


It's only one line more and this is still readable / elegant. And it works.

Comments (0)