The webrick of redmine has couple of performance issues, so I was looking for an alternative solution to avoid the use of apache and its proxy features. As already I use nginx it was clear to use it. The proxy is working perfectly with proxy_pass to the webrick, but this still have the performance issues.
I have decided that the uploaded files will be served by nginx directly so the configuration for it is the following:
server { listen 80; server_name redmine.local; root /opt/redmine/public; charset utf-8; access_log logs/redmine.local-access.log main; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_read_timeout 300; if (-f $request_filename/index.html) { rewrite (.*) $1/index.html break; } if (-f $request_filename.html) { rewrite (.*) $1.html break; } if (-f $request_filename.txt) { rewrite (.*) $1.txt break; } proxy_pass http://mongrel/; } } |
what is proxy_pass http://mongrel/;
? In nginx you can declare upstream where you can proxy some request.
In my case the declaration is:
upstream mongrel { server 127.0.0.1:8000; server 127.0.0.1:8001; server 127.0.0.1:8002; } |
You have to install mongrel_cluster and copy the init script to its place
server ~ / $ gem install mongrel_cluster server ~ / $ cp /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/resources/mongrel_cluster /etc/init.d/ server ~ / $ chmod +x /etc/init.d/mongrel_cluster |
than you have to configure the mongrel cluster with the following command:
server ~ / $ mkdir /etc/mongrel_cluster server ~ / $ mongrel_rails cluster::configure -e production -p 8000 -N 3 \ -c /opt/redmine/ –user nginx –group nginx \ -C /etc/mongrel_cluster/redmine.yml |
Now set the file and folder ownership and permissions
server ~ / $ chown -R nginx:nginx /opt/redmine server ~ / $ chmod -R 775 /opt/redmine |
Now we can start our mongrel cluster with:
server ~ / $ nginx -s stop server ~ / $ nginx server ~ / $ /etc/init.d/mongrel_cluster start |