Changes between Version 26 and Version 27 of TracNginxRecipe
- Timestamp:
- Jun 27, 2016, 10:59:23 AM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracNginxRecipe
v26 v27 1 1 [[PageOutline(2-5,Contents,pullout)]] 2 2 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 5 This 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 7 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. 8 9 == Why you should use tracd behind Nginx 10 11 This 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. 10 12 11 13 Here are the steps you need to take: 12 14 13 15 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 Mode16 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 18 20 19 21 When 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]: … … 21 23 * apache/mod_python was causing strange occasional delays, likely related to the segfaults. 22 24 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. 24 26 25 27 == Tracd - Trac's light and fast embedded web server … … 27 29 Run multiple tracd instances. This offers a speed benefit if you use [http://fasterfox.mozdev.org/ FasterFox], as well as good concurrency responsiveness. 28 30 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:31 Using the Gentoo init system, it is easy to create simple init scripts, which are attached to this page. Here is a simplified example: 30 32 31 33 '''Multi-Site tracd Startup''': works with Trac-0.10 and up: … … 52 54 server 127.0.0.1:3050; 53 55 server 127.0.0.1:3051; 54 #[... up to the number of instance, or more, if you want to be free toadd more ...]56 #[... up to the number of instance, or more, if you want to add more ...] 55 57 } 56 58 … … 69 71 # proxy_set_header Host $host; 70 72 } 71 72 73 } 73 74 }}} … … 86 87 server 127.0.0.1:3050; 87 88 server 127.0.0.1:3051; 88 #[... up to the number of instance, or more, if you want to be free toadd more ...]89 #[... up to the number of instance, or more, if you want to add more ...] 89 90 } 90 91 … … 117 118 proxy_pass http://live_trachosts_com; 118 119 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: 120 121 # proxy_redirect on; 121 122 # proxy_set_header Host $host; 122 123 } 123 124 124 } 125 125 } … … 128 128 === Static Content 129 129 130 Serving static files from htdocs dir ala /<site>/chrome/sitealiases `http://live.trachosts.com/myproj/chrome/site` to `/var/trachosts/trac/myproj/htdocs`:130 Serving 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`: 131 131 {{{#!nginx 132 132 location ~ /(.*?)/chrome/site/ { … … 150 150 ServerAdmin webmaster@trachosts.com 151 151 152 # in order to support COPY and MOVE, etc -over https (443),152 # in order to support COPY and MOVE, etc over https (443), 153 153 # ServerName _must_ be the same as the nginx servername 154 154 ServerName live.trachosts.com