My os x nginx configuration

First, to install nginx do this :

sudo port install nginx

then use this configuration – this is only for testing, with setting for my os x (for access log / pids). It also use proxy to merb

# nginx using macports installation
# for my local testing
user kusno staff;
worker_processes  1;

pid /opt/local/var/run/nginx.pid;
error_log  /opt/local/var/log/nginx/error.log  info;

events {
    worker_connections  16;
}

http {
  include        etc/nginx/mime.types;
  default_type   application/octet-stream;
  access_log /opt/local/var/log/nginx/access.log;
  sendfile        on;
  #tcp_nopush     on;
  keepalive_timeout  65;
  tcp_nodelay        on;
  gzip  on;
  gzip_min_length  1100;
  gzip_buffers     4 8k;
  gzip_types       text/plain;
  client_max_body_size 100m;

  upstream merb {
    server 127.0.0.1:4000;
  }

  server {
    listen       80;
    server_name  localhost;
    
    root /Users/kusno/ezify/public;
    
    index  index.html index.htm;

    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 false;
      #if (-f $request_filename/index.html) {
      #  rewrite (.*) $1/index.html break;
      #}
      #if (-f $request_filename.html) {
      #  rewrite (.*) $1.html break;
      #}
      if (-f $request_filename) {
        rewrite (.*) $1 break;
      }
      if (!-f $request_filename) {
        proxy_pass http://merb;
        break;
      }
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
  }
}

use this to restart nginx :

sudo launchctl stop org.macports.nginx
sudo launchctl start org.macports.nginx

Tags: