Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Version 2 (modified by cliff, 13 years ago) (diff)


Nginx is a fast and light HTTP server, reverse proxy, load balancer (and more).

It's pretty simple to get TurboGears setup behind a Nginx server. Here's a sample configuration that not only proxies to your TurboGears application, but serves static content and load balances it as well.

http {
    # boilerplate nginx config ...

    upstream mycluster { 

    server {
        listen 80;

        # static files
        location ~ ^/(images|javascript|js|css|flash|media|static)/  {
            root /var/www/myproject/myproject/static;
        location = /favicon.ico  {
            root /var/www/myproject/myproject/static/images;
        # proxy to turbogears app
        location / {
            proxy_pass              http://mycluster;
            proxy_redirect          off;
            proxy_set_header        Host $host;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

Next you need to setup a couple TurboGears backends that will comprise the cluster:

Edit prod.cfg and add/change the following lines:


Copy prod.cfg to prod2.cfg and add/change the following lines:


Start both instances (probably in separate terminals):

./ prod.cfg 
./ prod2.cfg 

That's it! Nginx should now be passing requests across both backends transparently.