1 ## http://brainspl.at/nginx.conf.txt
3 #user and group to run as
6 # number of nginx workers
9 # pid of nginx master process
10 pid /var/run/nginx.pid;
12 # Number of worker connections. 1024 is a good default
14 worker_connections 1024;
17 # start the http module where we config http access.
19 # pull in mime-types. You can break out your config
20 # into as many include's as you want to make it cleaner
21 include /etc/nginx/mime.types;
23 # set a default type for the rare situation that
24 # nothing matches from the mimie-type include
25 default_type application/octet-stream;
27 # configure log format
28 log_format main '$remote_addr - $remote_user [$time_local] $status '
29 '"$request" $body_bytes_sent "$http_referer" '
30 '"$http_user_agent" "http_x_forwarded_for"';
33 access_log /var/log/nginx/access.log main;
36 error_log /var/log/nginx/error.log debug;
37 #error_log logs/error.log debug_http;
42 # These are good default values.
45 # output compression saves bandwidth
47 gzip_http_version 1.0;
50 gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml
51 application/xml+rss text/javascript;
53 # this is where you define your mongrel clusters.
54 # you need one of these blocks for each cluster
55 # and each one needs its own name to refer to it later.
57 server 127.0.0.1:8000;
58 server 127.0.0.1:8001;
61 # the server directive is nginx's virtual host directive.
63 # port to listen on. Can also be set to an IP:PORT
66 # sets the domain[s] that this vhost server requests for
67 server_name lyrix.ubuntu;
70 root /var/www/apps/lyrix/current/public;
72 # vhost specific access log
73 access_log /var/log/nginx/lyrix.access.log main;
75 #Set the max size for file uploads to 50Mb
76 client_max_body_size 50M;
78 # this rewrites all the requests to the maintenance.html
79 # page if it exists in the doc root. This is for capistrano's
81 if (-f $document_root/maintenance.html){
82 rewrite ^(.*)$ /maintenance.html last;
87 rewrite ^(.*)$ http://lyrix.ubuntu$1 redirect;
94 # needed to forward user's IP address to rails
95 proxy_set_header X-Real-IP $remote_addr;
98 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
99 proxy_set_header Host $http_host;
100 proxy_redirect false;
101 proxy_max_temp_file_size 0;
103 # check for index.html for directory index
104 # if its there on the filesystem then rewite
105 # the url to add /index.html to the end of it
106 # and then break to send it to the next config rules.
107 if (-f $request_filename/index.html) {
108 rewrite (.*) $1/index.html break;
111 # this is the meat of the rails page caching config
112 # it adds .html to the end of the url and then checks
113 # the filesystem for that file. If it exists, then we
114 # rewite the url to have explicit .html on the end
115 # and then send it on its way to the next config rule.
116 # if there is no file on the fs then it sets all the
117 # necessary headers and proxies to our upstream mongrels
118 if (-f $request_filename.html) {
119 rewrite (.*) $1.html break;
122 if (!-f $request_filename) {
123 proxy_pass http://lyrix;
128 error_page 500 502 503 504 /50x.html;
129 location = /50x.html {