Dev: February 2008 Archives

Further nginx work

|

A little while ago, I mentioned the web server Nginx, and had planned to do some fooling with it to see how it handled proxying for a mongrel cluster. I had a spare 20 minutes today, and in the time frame I was able to install Nginx, put together a config file, install mongrel and the cluster controller, and put together a simple Rails app for testing. After realizing I had a typo in my config file, it was up and running like a dream. My config files:

mongrel_cluster.yml


1 user: mongrel
2 cwd: /home/pratzsch/apps/demo
3 log_file: log/mongrel.log
4 port: "5001"
5 environment: development
6 group: mongrel
7 address: 127.0.0.1
8 pid_file: /etc/mongrel.pid
9 servers: 3


nginx.conf


1 user www-data;
2 worker_processes 2;
3
4 error_log /var/log/nginx/error.log notice;
5 pid /var/run/nginx.pid;
6
7 events {
8 worker_connections 1024;
9 }
10
11 http {
12 include /etc/nginx/mime.types;
13 default_type application/octet-stream;
14 access_log /var/log/nginx/access.log
15
16 sendfile on;
17 tcp_nopush on;
18
19 keepalive_timeout 65;
20 tcp_nodelay on;
21
22 upstream mongrel {
23 server 127.0.0.1:5001;
24 server 127.0.0.1:5002;
25 server 127.0.0.1:5003;
26 }
27
28 gzip on;
29 gzip_min_length 1100;
30 gzip_buffers 4 8k;
31 gzip_types text/plain;
32
33 server {
34 listen 80;
35 server_name localhost;
36 root /etc/public;
37
38 access_log off;
39 rewrite_log on;
40
41 location ~ ^/$ {
42 if (-f /index.html){
43 rewrite (.*) /index.html last;
44 }
45
46 proxy_pass http://mongrel;
47 }
48
49 location / {
50 if (!-f $request_filename.html) {
51 proxy_pass http://mongrel;
52 }
53
54 rewrite (.*) $1.html last;
55 }
56
57 location ~ .html {
58 root /etc/public;
59 }
60
61 location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xl s|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)$ {
62 root /etc/public;
63 }
64
65 location / {
66 proxy_pass http://mongrel;
67 proxy_redirect off;
68 proxy_set_header Host $host;
69 proxy_set_header X-Real-IP $remote_addr;
70 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
71 }
72
73 }
74 }

That's all there is to it. The mongrel_cluster_ctl command can seem to be a little tempermental, but one adjusts to it quickly.

This stack in my view beats the pants off of the Apache2.2 solution.

Day of experimenting

|

Pet peeve of the day: TV shows and movies using 'upload' and 'download' incorrectly.

Today I fooled around with Nginx ("Engine X"), an alternative to the ubiquitous Apache web server. I haven't seen anyone use it, although it's apparently quite popular in Russia. I'm planning on configuring it to proxy for a Mongrel cluster, do some load testing, and see how it compares to the 'standard' Apache 2.2/mod_proxy/mod_proxy_balancer/Mongrel cluster stack.

I also spent some time this evening fooling with Citadel, an open source Exchange replacement. To summarize Linux Journal's opinion, yeah, go ahead and throw Exchange away. In shorter, badass.

Finally, I started the day by working on a Rails-based Tic Tac Toe program that plays itself using web services. Not that there's a huge marker for things like this, but it was a good learning experience.

About this Archive

This page is a archive of entries in the Dev category from February 2008.

Dev: March 2008 is the next archive.

Find recent content on the main index or look in the archives to find all content.