Grok, Virtual Hosting and Nginx
This How-to applies to:
Any version.
This How-to is intended for:
Any audience.
Zope 3 and thus Grok supports virtual hosting straight out of the box. The super fast and lightweight Nginx HTTP server does this too. In fact, it is so easy to congfigure even a caveman could do it... so I did.
This is a stripped down version of [nginx.conf] with only the relevant statements included. Add these in the appropriate places to the default nginx.conf and you will be cooking in no time.
1 2 3 4 5 6 7 8 9 10 11 12 | http {
upstream mygrokinstance {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name www.example.com;
location / {
proxy_pass http://mygrokinstance/grok_application_name/++vh++http:www.example.com:80/++;
}
}
}
|
Explanation:
- 2-4:
- Defining a backend server mygrokinstance. This also allows me to add simple load-balancing (round-robin and client IP) by adding an extra line for each server.
- 5-11:
- Server directives...
- 6:
- The port that Nginx listens to.
- 7:
- The domain name used to access the application.
- 8-10:
- The rewrite rule.
- 8:
- location / corresponds to anything. location /application would equal anything starting with www.example.com/application
- 9:
The rewrite rule, where:
mygrokinstance is the backend server that we defined on row 3-5
grok_application_name/ is the application name since I don't want to have to include it in the URLs
http:www.example.com:80/ tells zope to generate the URLs without the application name
More on Nginx:
http://wiki.codemongers.com/Main
Virtual hosting in Zope 3:
http://wiki.zope.org/zope3/virtualhosting.html
The Nginx upstream command:
http://wiki.codemongers.com/NginxHttpUpstreamModule
see also:
-
Use Apache HTTP server with Grok (on Debian Sid)
- This Grok How-To gives a step-by-step explanation of how to install and configure Apache HTTP server version 2.2 on Debian Sid to serve Grok Web Applications using the mod_rewrite method.

