Edgewall Software

Changes between Version 26 and Version 27 of TracNginxRecipe


Ignore:
Timestamp:
Jun 27, 2016, 10:59:23 AM (8 years ago)
Author:
figaro
Comment:

Further cosmetic changes

Legend:

Unmodified
Added
Removed
Modified
  • TracNginxRecipe

    v26 v27  
    11[[PageOutline(2-5,Contents,pullout)]]
    22
    3 = Using Nginx as your main web server for multiple Trac Projects
    4 
    5 This recipe below describes some setups where [http://www.nginx.net/ Nginx] is your main webserver. Nginx is an Apache replacement by [http://sysoev.ru/en/ Igor Sysoev]. First set up Nginx as your main web server and then set up multiple instances of Tracd Web Server. Trac has an embedded webserver that is included in Trac and called Tracd. Then you have Nginx serve requests to your Tracd web server instances.
    6 
    7 == Why you should use Tracd behind Nginx
    8 
    9 This is a setup where Nginx acts as a load balancer. Tracd is lightweight and fast and it is easy to get working with Trac. You can start multiple instances of the Tracd web server on different ports for different Trac projects. Nginx as your main webserver can serve requests to these instances of the Tracd web server. This also works for multiple Trac Projects on multiple vhosts. In short it's fast, lightweight, and easy to set up.
     3= Using Nginx as your main web server for multiple Trac projects
     4
     5This recipe below describes some setups of the [http://www.nginx.net/ Nginx] webserver in your Trac project. Nginx is an Apache replacement for load balancing purposes among other things and is written by [http://sysoev.ru/en/ Igor Sysoev].
     6
     7First set up '''Nginx''' as your main web server and then set up multiple instances of '''tracd''' web server. Trac has an embedded webserver that is included in Trac and called tracd. Then you have Nginx serve requests to your tracd web server instances.
     8
     9== Why you should use tracd behind Nginx
     10
     11This is a setup where Nginx acts as a load balancer. In addition, Tracd is lightweight and fast and it is easy to get working with Trac. You can start multiple instances of the tracd web server on different ports for different Trac projects. Nginx as your main webserver can serve requests to these instances of the tracd web server. This also works for multiple Trac Projects on multiple vhosts. In short it's fast, lightweight, and easy to set up.
    1012
    1113Here are the steps you need to take:
    1214
    1315 1. Set up Nginx as your main webserver on port 80.
    14  1. Start multiple instances of the Tracd embedded web server on different ports for each Trac project.
    15  1. Configure Nginx to serve requests to your various running instances of Tracd webserver.
    16 
    17 == Using Tracd with Nginx in Cluster Mode
     16 1. Start multiple instances of the tracd embedded web server on different ports for each Trac project.
     17 1. Configure Nginx to serve requests to your various running instances of tracd webserver.
     18
     19== Using tracd with Nginx in Cluster Mode
    1820
    1921When using Trac and Apache with multiple vhosts, and multiple Trac sites per vhost, and upgrading from Subversion 1.2.3 to 1.4, we hit [ticket:2611 this bug]:
     
    2123 * apache/mod_python was causing strange occasional delays, likely related to the segfaults.
    2224
    23 '''Caveat''': Only use this with PostgreSQL. If you want to do this, but are on SQLite, then use Pacopablos [http://trac-hacks.org/wiki/SqliteToPgScript Sqlite-to-Pg] script. We use it here, and it's great.
     25'''Caveat''': Only use this with PostgreSQL. If you want to do this, but are on SQLite, then use Pacopablos [th:SqliteToPgScript Sqlite-to-Pg] script. We use it here, and it's great.
    2426
    2527== Tracd - Trac's light and fast embedded web server
     
    2729Run multiple tracd instances. This offers a speed benefit if you use [http://fasterfox.mozdev.org/ FasterFox], as well as good concurrency responsiveness.
    2830
    29 Using the Gentoo init system, it was easy to create simple init scripts, which are attached to this page. Here is a simplified example:
     31Using the Gentoo init system, it is easy to create simple init scripts, which are attached to this page. Here is a simplified example:
    3032
    3133'''Multi-Site tracd Startup''': works with Trac-0.10 and up:
     
    5254          server  127.0.0.1:3050;
    5355          server  127.0.0.1:3051;
    54           #[... up to the number of instance, or more, if you want to be free to add more ...]
     56          #[... up to the number of instance, or more, if you want to add more ...]
    5557  }
    5658 
     
    6971                  # proxy_set_header Host $host;
    7072          }
    71  
    7273  }
    7374}}}
     
    8687          server  127.0.0.1:3050;
    8788          server  127.0.0.1:3051;
    88           #[... up to the number of instance, or more, if you want to be free to add more ...]
     89          #[... up to the number of instance, or more, if you want to add more ...]
    8990  }
    9091 
     
    117118                  proxy_pass      http://live_trachosts_com;
    118119                  include         /etc/nginx/proxy.conf;
    119                   # my system doesn't have the proxy.conf file so I needed to add the following two lines to get redirects working:
     120                  # my system doesn't have the proxy.conf file so I added the following two lines to get redirects working:
    120121                  # proxy_redirect on;
    121122                  # proxy_set_header Host $host;
    122123          }
    123  
    124124  }
    125125}
     
    128128=== Static Content
    129129
    130 Serving static files from htdocs dir ala /<site>/chrome/site aliases `http://live.trachosts.com/myproj/chrome/site` to `/var/trachosts/trac/myproj/htdocs`:
     130Serving static files from the htdocs directory as in `/<site>/chrome/site` aliases `http://live.trachosts.com/myproj/chrome/site` to `/var/trachosts/trac/myproj/htdocs`:
    131131{{{#!nginx
    132132        location ~ /(.*?)/chrome/site/ {
     
    150150    ServerAdmin webmaster@trachosts.com
    151151
    152     # in order to support COPY and MOVE, etc - over https (443),
     152    # in order to support COPY and MOVE, etc over https (443),
    153153    # ServerName _must_ be the same as the nginx servername
    154154    ServerName live.trachosts.com