# Listen for www
server {

	# Config APP paths
	set $root_path /Users/delarueguillaume/Sites/wyrian/wyrian/guiltouf;
	
	# Server Config
	listen 80;
	server_name wyrian.socialmixmedia.fr;
	access_log /var/log/nginx/wyrian.access.log;
	
	# Set the max size for file uploads to 50Mb
	client_max_body_size 50M;
	
	location / {
		root $root_path;	
		index  index.php index.html index.htm;
		
		# needed to forward user'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 off;
		proxy_max_temp_file_size 0;
		
		# sitemap generator
		if ( $request_uri ~* ^/sitemap.xml ) {
			rewrite ^(.*)$ /sitemap.php;
		}
		
		# Rewrite non static files request to /index.php
		if (!-e $request_filename) {
			rewrite ^(.*)$ /index.php?q=$1;
		}
	}
	
	# Send php scripts to fastcgi
	location ~ \.php$ {
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME  $root_path/$fastcgi_script_name;
		include        fastcgi_params;
	}
	 
	# Set long expireation date and no log access
	location ~* ^.+\.(jpg|jpeg|gif|png|css|js)$ {
	        root         $root_path;
	        access_log   off;
	        expires      30d;
	}
	
	# Link common to core statics directly
	location ^~ /common/ {
		alias        /Users/delarueguillaume/Sites/Framework-Web2ajaX/core/statics/;
		access_log   off;
		expires      30d;
	}
	
	# Link to minify
	location ^~ /min/ {
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME  /Users/delarueguillaume/Sites/Framework-Web2ajaX$fastcgi_script_name;
		fastcgi_param  WWW_PATH  /Users/delarueguillaume/Sites/wyrian/wyrian;
		include        fastcgi_params;
	}
	
	# Deny access to protected dirs
	location ~ ^/nginx-conf/(.*)$ { deny  all; }
	location ~ /\.ht { deny  all; }
}

