upstream backend {
	server localhost:9001;
	keepalive 12000;
}
server {
	listen 443 ssl http2;
	server_name ws.especificosba.com.ar;
	include /etc/nginx/ssl;
	root /tmp/;
	location / {
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
		proxy_http_version 1.1;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header Host $host;
		proxy_pass http://backend;
		proxy_read_timeout 12000;
	}
}
server {
	listen 80;
	server_name plataforma.especificosba.com.ar;
	rewrite ^ https://plataforma.especificosba.com.ar permanent;
}
server {
	listen   443 ssl http2; 
	include /etc/nginx/ssl;

	root /var/www/cursos-ng;
	index index.php index.html index.htm;

	log_not_found on;
	access_log /var/log/nginx/access_plataforma.eba.com.log ;
	error_log /var/log/nginx/error_plataforma.eba.com.log ;
	server_name plataforma.especificosba.com.ar;
	location / {
		try_files $uri $uri/ /index.html;
	}

	location ~ \.php$ {
        try_files $uri =404;
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
		fastcgi_pass unix:/var/run/php5-fpm.sock;
		fastcgi_index index.php;
		include fastcgi_params;
		fastcgi_param   PATH_INFO         $fastcgi_path_info;
		fastcgi_param   SCRIPT_FILENAME   $document_root$fastcgi_script_name;

	}

	location /dash {
		root /tmp/;
		add_header 'Access-Control-Allow-Origin' '*';
		add_header 'Cache-Control' 'no-cache';
	}

	location /hls {
		#sendfile off;
		#tcp_nopush on;
		#directio 512;
		open_file_cache off;
		types {
			application/vnd.apple.mpegurl m3u8;
			video/mp2t ts;
		}
		root /tmp/;
		add_header 'Access-Control-Allow-Origin' '*';
		add_header 'Cache-Control' 'no-cache';
	}
	location /stat {
        rtmp_stat all;
        rtmp_stat_stylesheet stat.xsl;
		deny 127.0.0.2;
    }
	
    location /stat.xsl {
        root /var/www/eba/ELearning/;			
    }
	location /ws/ {
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
		proxy_http_version 1.1;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header Host $host;
		proxy_pass http://backend;
		proxy_read_timeout 12000;
	}
	location ~ ^/directives/templates/.+\.html$ {
		expires off;
		sendfile off;
		add_header "Cache-Control" "no-cache";
		break;
	}
	location ~ ^/images/perfiles/.+\.jpg$ {
		try_files $uri /images/perfiles/default.png;
	}
	location ~* ^.+\.(?:js|jpe?g|gif|png|ttf|woff)$ {
        access_log off;
        expires 10d;
        tcp_nodelay on;
        open_file_cache max=3000 inactive=120s;
        open_file_cache_valid 45s;
        open_file_cache_min_uses 2;
        open_file_cache_errors off;
    }
}
