user root root;
worker_processes  1;
worker_priority	0;

#error_log  /tmp/log/nginx.error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       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"';

    
    log_format access '$remote_addr - $remote_user [$time_local] "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for"';
    #open_log_file_cache max=1000 inactive=20s min_uses=1 valid=1m;
    error_log  /tmp/log/nginx.error.log debug;
    #access_log  /tmp/log/access.log;
    access_log  /dev/null;
    sendfile        on;
    #tcp_nopush     on;
    client_max_body_size 100m;
    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

	

 server {
        listen       8888;
        server_name  127.0.0.1;

        # rtmp stat
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
        location /stat.xsl {
            root /usr/nginx;
        }

        # rtmp control
        location /control {
            rtmp_control all;
        }
    }

	server {
        listen       8801;
        server_name  flv1;

		location /flv {
#		   flv_live on;
		}
	}

    server {
        listen       8802;
        server_name  flv2;

#		location /flv {
#		   flv_live on;
#		}
	}


    server {
        listen       88;
        server_name  proxy;

	location / {
   	    proxy_pass      http://127.0.0.1/;
	    proxy_max_temp_file_size 0m;
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Headers X-Requested-With,content-type;
            add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
	}

	location /live {
		deny all;
	}

	location /hls {
		deny all;
	}

	location /flv {
		deny all;
	}
    }

    server {
        listen       80;
        server_name  127.0.0.1;



        location / {
            ssi on;
            root   /link/web;
            index  dashboard.php;

        }
        
	location /RPC {
	    proxy_pass      http://127.0.0.1:6001/RPC;
	    proxy_max_temp_file_size 0m;
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Headers X-Requested-With,content-type;
            add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
	}
	
	location /RPC2 {
	    proxy_pass      http://127.0.0.1:6002/RPC;
	    proxy_max_temp_file_size 0m;
	}
	
	location /RPC3 {
	    proxy_pass      http://127.0.0.1:6003/RPC;
	    proxy_max_temp_file_size 0m;
	}

	location /RPC4 {
	    proxy_pass      http://127.0.0.1:6004/RPC;
	    proxy_max_temp_file_size 0m;
	}
	
	location ~ /socket.io {   
	    proxy_pass http://127.0.0.1:7857;
	    proxy_http_version 1.1;
	    proxy_set_header Upgrade $http_upgrade;
	    proxy_set_header Connection "Upgrade";
	    proxy_set_header X-Real-IP $remote_addr;
	}  
        
        location  /snap/ {
            alias   /tmp/snap/;
#            add_header Cache-Control no-store;
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Headers X-Requested-With,content-type;
            add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
        }
        
        location /hls/ {
            alias /tmp/hls/;
        }
        
        location /config/ {
            alias /link/config/;
			add_header Cache-Control no-store;
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Headers X-Requested-With,content-type;
            add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
        }

		location /alarm/ {
            alias /link/web/alarm/;
            autoindex on;
            autoindex_format json;
        }
        
        location /res/ {
            alias /link/res/;
            autoindex on;
            autoindex_format json;
        }

		location /files/ {                                                 
            alias /root/usb/;
			mp4;
            autoindex on;
            autoindex_format json;                  
        }
        
        location /usb/ {                                                 
            alias /root/usb/;                                            
            autoindex on;                                                
            autoindex_format json;                    
        }

		location /LinkScript/ {
            alias /link/script/;
        }
        
        location /live/ {
       	    rewrite '^/live/(.*)$' http://$host:8090/$1 permanent;
        }

	location /flv {
            flv_live on;
	    add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
        }
	include /link/web/.htaccess;
	location ~\.php$ {
            root           /link/web;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  dashboard.php;
            index dashboard.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
	    include        fastcgi.conf;
        }
	
    }

}

include /link/config/rtmp.conf;


