# Mapping of 
#
# From the /mitx directory:
#   /usr/local/Cellar/nginx/1.2.2/sbin/nginx -p `pwd`/ -c nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    ##
    # Basic Settings
    ##
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;
    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /usr/local/etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Gzip Settings
    ##
    gzip on;
    gzip_disable "msie6";

    upstream portal {
        server localhost:8000;
    }

    upstream course_harvardx_cs50_2012 {
        server localhost:8001;
    }

    upstream course_mitx_6002_2012_fall {
        server localhost:8002;
    }

    # Mostly copied from our existing server...
    server {
      listen 8100 default_server;

      rewrite ^(.*)/favicon.ico$ /static/images/favicon.ico last;

      # Our catchall 
      location / {
        proxy_pass http://portal;
      }

      location /courses/HarvardX/CS50x/2012/ {
        proxy_pass http://course_harvardx_cs50_2012;
      }

      location /courses/MITx/6.002x/2012_Fall/ {
        proxy_pass http://course_mitx_6002_2012_fall;
      }

      location ~ /courses/([^/]*)/([^/]*)/([^/]*)/(course_wiki|wiki) {
        proxy_pass http://portal;
      }

    }
}


