<?xml version="1.0" encoding="UTF-8"?>
<OAI-PMH xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.openarchives.org/OAI/2.0/">
  <responseDate>2010-03-12T04:40:36Z</responseDate>
  <request identifier="oai:kete.net.nz:documentation:Document:17" verb="GetRecord" metadataPrefix="oai_dc">http://kete.net.nz/documentation/documents/show/17-example-nginx-configuration-file-simple-installation</request>
  <GetRecord>
    <record>
      <header>
        <identifier>oai:kete.net.nz:documentation:Document:17</identifier>
        <datestamp>2009-07-14T09:59:26Z</datestamp>
      </header>
      <metadata>
        <oai_dc:dc xmlns:dcterms="http://purl.org/dc/terms/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/">
          <dc:identifier>http://kete.net.nz/documentation/documents/show/17-example-nginx-configuration-file-simple-installation</dc:identifier>
          <dc:title>Example Nginx Configuration File Simple Installation</dc:title>
          <dc:publisher>kete.net.nz</dc:publisher>
          <dc:description><![CDATA[A template for your simple installation nginx configuration file.  Edit to suit.]]></dc:description>
          <dc:description><![CDATA[
	Walter McGinnis, 2007-08-13
	updated based on http://brainspl.at/nginx.conf.txt
	see there for comments on each option
user  your_user_account your_user_account_or_group_if_different;

worker_processes  6;
pid  logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       conf/mime.types;
    default_type  application/octet-stream;

	configure log format
    log_format main &#8216;$remote_addr &#8211; $remote_user [$time_local] &#8217;
                    &#8217;&quot;$request&quot; $status $body_bytes_sent &#8220;$http_referer&#8221; &#8217;
                    &#8217;&quot;$http_user_agent&quot; &#8220;$http_x_forwarded_for&#8221;&#8217;;

access_log  logs/access.log  main;

	main error log
    error_log  logs/nginx_error.log debug;


	rewrite_log on; # I have yet to find where this gets saved to :(

sendfile       on;
tcp_nopush     on;
tcp_nodelay    off;

	output compression saves bandwidth
    gzip            on;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_types      text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;


	your_app -&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-


	redirect &#8220;www.your_app.com&#8221; to &#8220;your_app.com&#8221;
	you may want to do the reverse
    server {
        listen       80;
        server_name  www.your_app.com;
        location / {
              rewrite ^(.*)$ http://your_app.com$1 last;
        }
    }

server {
listen       443;
server_name  www.your_app.com;
location / {
rewrite ^(.*)$ https://your_app.com$1 last;
}
}

	add listeners on ports here as needed for your mongrel cluster
	i.e.      server 127.0.0.1:8001;
	server 127.0.0.1:8002;
	etc
    upstream your_app {
        server 127.0.0.1:8000;
    }


	for non-ssl traffic, i.e. http
    server {
        listen       80;
        server_name  your_app.com;


	Set the max size for file uploads
	we set this high here and manage it
	within our app&#8217;s system setting for max file size
        client_max_body_size 500M;

access_log  logs/access.your_app.log  main;
error_log   logs/error.your_app.log   debug;

	doc root
        root /your_home_directory_path/apps/your_app/public;


	this rewrites all the requests to the maintenance.html
	page if it exists in the doc root. This is for capistrano&#8217;s
	disable web task
        if (-f $document_root/system/maintenance.html) {
              rewrite  ^(.*)$  /system/maintenance.html last;
              break;
        }

location / {

	needed to forward user&#8217;s IP address to rails
                proxy_set_header  X-Real-IP  $remote_addr;


	needed for HTTPS
                proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_redirect false;
                proxy_max_temp_file_size 0;


	If the file exists as a static file serve it directly without
	running all the other rewite tests on it
              if (-f $request_filename) {
                break;
              }


	check for index.html for directory index
	if its there on the filesystem then rewite
	the url to add /index.html to the end of it
	and then break to send it to the next config rules.
              if (-f $request_filename/index.html) {
                rewrite (.*) $1/index.html break;
              }


	this is the meat of the rails page caching config
	it adds .html to the end of the url and then checks
	the filesystem for that file. If it exists, then we
	rewite the url to have explicit .html on the end
	and then send it on its way to the next config rule.
	if there is no file on the fs then it sets all the
	necessary headers and proxies to our upstream mongrels
              if (-f $request_filename.html) {
                rewrite (.*) $1.html break;
              }

if (!-f $request_filename) {
proxy_pass http://your_app;
break;
}
}
error_page   500 502 503 504  /500.html;
location = /500.html {
root   /your_home_directory_path/apps/your_app/public;
}
}

	for ssl encrypted traffic, i.e. https
    server {
        listen       443;
        server_name  your_app.com;


	Set the max size for file uploads
	we set this high here and manage it
	within our app&#8217;s system setting for max file size
        client_max_body_size 500M;

access_log  logs/access.your_app.log  main;
error_log   logs/error.your_app.log   debug;

	doc root
        root /your_home_directory_path/apps/your_app/public;


	this rewrites all the requests to the maintenance.html
	page if it exists in the doc root. This is for capistrano&#8217;s
	disable web task
        if (-f $document_root/system/maintenance.html) {
              rewrite  ^(.*)$  /system/maintenance.html last;
              break;
        }

location / {

	needed to forward user&#8217;s IP address to rails
                proxy_set_header  X-Real-IP  $remote_addr;


	needed for HTTPS
                proxy_set_header X_FORWARDED_PROTO https;

proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
proxy_max_temp_file_size 0;

	If the file exists as a static file serve it directly without
	running all the other rewite tests on it
              if (-f $request_filename) {
                break;
              }


	check for index.html for directory index
	if its there on the filesystem then rewite
	the url to add /index.html to the end of it
	and then break to send it to the next config rules.
              if (-f $request_filename/index.html) {
                rewrite (.*) $1/index.html break;
              }


	this is the meat of the rails page caching config
	it adds .html to the end of the url and then checks
	the filesystem for that file. If it exists, then we
	rewite the url to have explicit .html on the end
	and then send it on its way to the next config rule.
	if there is no file on the fs then it sets all the
	necessary headers and proxies to our upstream mongrels
              if (-f $request_filename.html) {
                rewrite (.*) $1.html break;
              }

if (!-f $request_filename) {
proxy_pass http://your_app;
break;
}
}
error_page   500 502 503 504  /500.html;
location = /500.html {
root   /your_home_directory_path/apps/your_app/public;
}
}
}]]></dc:description>
          <dc:source>http://kete.net.nz/documents/0000/0000/0017/nginx-conf-example.txt</dc:source>
          <dc:date>2008-01-06T13:12:11Z</dc:date>
          <dc:creator>Walter McGinnis</dc:creator>
          <dc:creator>walter</dc:creator>
          <dc:contributor>Ahmad Maher</dc:contributor>
          <dc:contributor>AhmadMaher</dc:contributor>
          <dc:description/>
          <dc:subject><![CDATA[Configure Nginx Web Proxy]]></dc:subject>
          <dc:relation>http://kete.net.nz/documentation/topics/show/123</dc:relation>
          <dc:subject><![CDATA[Installation]]></dc:subject>
          <dc:relation>http://kete.net.nz/documentation/topics/show/114</dc:relation>
          <dc:type>InteractiveResource</dc:type>
          <dc:subject><![CDATA[Kete]]></dc:subject>
          <dc:subject><![CDATA[Installation]]></dc:subject>
          <dc:subject><![CDATA[Nginx]]></dc:subject>
          <dc:subject><![CDATA[install]]></dc:subject>
          <dc:subject><![CDATA[setup]]></dc:subject>
          <dc:subject><![CDATA[configure]]></dc:subject>
          <dc:rights>http://kete.net.nz/about/topics/show/4-terms-and-conditions</dc:rights>
          <dc:format>text/plain</dc:format>
        </oai_dc:dc>
      </metadata>
      <kete>
        <related_items topics="2"/>
        <media_content src="http://kete.net.nz/documents/0000/0000/0017/nginx-conf-example.txt" content_type="text/plain" size="7216"/>
      </kete>
    </record>
  </GetRecord>
</OAI-PMH>
