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

Changes between Version 3 and Version 4 of NginxIntegration


Ignore:
Timestamp:
03/04/08 19:23:20 (11 years ago)
Author:
Chris Arndt
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NginxIntegration

    v3 v4  
    1 Nginx is a fast and light HTTP server, reverse proxy, load balancer (and more). 
     1{{{ 
    22 
    3 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. 
     3#!rst 
    44 
    5 {{{ 
    6 http { 
    7     # boilerplate nginx config ... 
    8  
    9     upstream mycluster {  
    10         server 127.0.0.1:8000; 
    11         server 127.0.0.1:8001; 
    12     } 
    13  
    14     server { 
    15         listen 80; 
    16  
    17         # static files 
    18         location ~ ^/(images|javascript|js|css|flash|media|static)/  { 
    19             root /var/www/myproject/myproject/static; 
    20         } 
    21         location = /favicon.ico  { 
    22             root /var/www/myproject/myproject/static/images; 
    23         } 
    24        
    25         # proxy to turbogears app 
    26         location / { 
    27             proxy_pass              http://mycluster; 
    28             proxy_redirect          off; 
    29             proxy_set_header        Host $host; 
    30             proxy_set_header        X-Real-IP $remote_addr; 
    31             proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for; 
    32         } 
    33 } 
     5.. note:: This page has been migrated to http://docs.turbogears.org/1.0/BehindNginx 
    346}}} 
    357 
    36 Next you need to setup a couple TurboGears backends that will comprise the cluster: 
    37  
    38 Edit prod.cfg and add/change the following lines: 
    39 {{{ 
    40 server.socket_host="127.0.0.1" 
    41 server.socket_port=8000 
    42 }}} 
    43  
    44 Copy prod.cfg to prod2.cfg and add/change the following lines: 
    45 {{{ 
    46 server.socket_host="127.0.0.1" 
    47 server.socket_port=8001 
    48 }}} 
    49  
    50 Start both instances of your app: 
    51 {{{ 
    52 ./start-myproject.py prod.cfg & 
    53 ./start-myproject.py prod2.cfg & 
    54 }}} 
    55  
    56 That's it!  Nginx should now be passing requests across both backends transparently. 
    57