##
#
# This configuration file is an example of how dmsmart platform can be configured for production purposes.
# It is ready to be deployed on Cloud. It optimizes traffic of static assets and automatically configure the routes
# which nginx must handle.
#
##

server {
	listen {{ip_address}}:{{http_port}};

	include /etc/nginx/uwsgi_params;

	error_log /var/log/nginx/{{vhost_name}} notice;
	rewrite_log on;
	
	root {{root_folder}};
	index index.html index.htm;

	# Make site accessible from http://{{vhost_name}}/
	server_name {{vhost_name}};
	server_name www.{{vhost_name}};

	set $modules_holder {{modules_folder}};
	
	location /favicon.ico {
		# Matching special favicon call.
		rewrite ^/favicon.ico $modules_holder/static/favicon.ico break;
		
		if (!-f $request_filename) {
		   uwsgi_pass {{ip_address}}:{{uwsgi_port}};
		}		
	}
		
	location / {
		# Matching normal modules static resources
		rewrite ^/(.*?)/static/(.*)$ $modules_holder/$1/static/$2 break;
	
		if (!-f $request_filename) {
		   uwsgi_pass {{ip_address}}:{{uwsgi_port}};
		}
	}	
}