
user www;
worker_processes 1;

#error_log /var/log/nginx/error.log  error;

pid /var/run/nginx.pid;

events {
	worker_connections 1024;
	use poll;
}


http {
	include       /etc/nginx/mime.types;
	default_type  application/octet-stream;

	log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
		'$status $body_bytes_sent "$http_referer" '
		'"$http_user_agent" "$http_x_forwarded_for"';

	#access_log  /var/log/nginx/access.log main;
	access_log off;

	sendfile        on;
	#tcp_nopush     on;

	#keepalive_timeout  0;
	keepalive_timeout  65;

	#gzip  on;

	upstream fcgi_backend {
		server localhost:9999;
		keepalive 10;
	}

	server {
		listen       80 default_server;
		server_name  _;
		charset utf-8;
		#access_log  /var/log/host.access.log main;
		root /www/;

		location / {
			index         index.html index.htm default.aspx Default.aspx;
			#try_files $uri $uri/ /public/index.php$request_uri;
		}

		location ~ ^/cgi-bin/.*\.x$ {
			root /usr/share/nginx/cgi-bin;
			include proxy.conf;
			proxy_pass http://127.0.0.1:8000;
		}

		location ~ .cgi$ {
			fastcgi_keep_conn on;
			include fastcgi_params;
			fastcgi_pass fcgi_backend;
		}

		# deny access to .htaccess files, if Apache's document root
		# concurs with nginx's one
		#
		location ~ /\.ht {
			deny  all;
		}

		location ~ /(\.|credentials.txt) 
		{ 
			deny all;
		}

		error_page 400 /errors/error.html?errc=400;
		error_page 401 /errors/error.html?errc=401;
		error_page 402 /errors/error.html?errc=402;
		error_page 403 /errors/error.html?errc=403;
		error_page 404 /errors/error.html?errc=404;
		#error_page 404 /cgi-bin/test.x;
		error_page 405 /errors/error.html?errc=405;
		error_page 406 /errors/error.html?errc=406;
		error_page 407 /errors/error.html?errc=407;
		error_page 408 /errors/error.html?errc=408;
		error_page 409 /errors/error.html?errc=409;
		error_page 410 /errors/error.html?errc=410;
		error_page 500 /errors/error.html?errc=500;
		error_page 501 /errors/error.html?errc=501;
		error_page 502 /errors/error.html?errc=502;
		error_page 503 /errors/error.html?errc=503;
		error_page 504 /errors/error.html?errc=504;
		error_page 505 /errors/error.html?errc=505;
		location /errors {
			ssi on;
			root /usr/share/nginx;
			set $page $request_uri;
			internal;
		}
		location /errimgs {
			root /usr/share/nginx;
		}
	}

	server {
		listen 443;
		ssl on;
		ssl_certificate      /etc/nginx/democert.pem;
		ssl_certificate_key  /etc/nginx/democert.key;
		charset utf-8;
		root /www/;

		location / {
			index         index.html index.htm default.aspx Default.aspx;
			#try_files $uri $uri/ /public/index.php$request_uri;
		}

		location /api {
			fastcgi_keep_conn on;
			include fastcgi_params;
			fastcgi_pass fcgi_backend;
		}

		location ~ \.cgi {
			fastcgi_keep_conn on;
			include fastcgi_params;
			fastcgi_pass fcgi_backend;
		}

		# deny access to .htaccess files, if Apache's document root
		# concurs with nginx's one
		#
		location ~ /\.ht {
			deny  all;
		}
	}
}

