
#user  nobody;
worker_processes  4;

#error_log  logs/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"';

    #access_log  logs/access.log  main;

    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;

    #keepalive_timeout  0;
    keepalive_timeout  60;

    #gzip  on;

    server_tokens     off;

    server {
        listen            8888;
        listen       [::]:8888;
        server_name  localhost;

        #charset      koi8-r;
        source_charset utf-8;
        charset        utf-8;

        #access_log  logs/host.access.log  main;

        location /file {
            root html;                               # 文件路径
            autoindex on;                            # 访问权限开启
            autoindex_exact_size off;                # 显示文件大小
            autoindex_localtime on;                  # 显示文件时间
            add_header Cache-Control no-cache;       # 防止跨域问题
        }

        location /flv {
            flv_live on;
            chunked_transfer_encoding off;
        }

        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root html;
        }

        location /app {
            proxy_pass http://backend_server;                            # 后端服务地址http://backend_server
            proxy_pass http://backend_server/;                           # 后端服务地址http://backend_server/app
            proxy_set_header Host $host;                                 # 传递客户端请求域名:ml-citation{ref="3,4" data="citationList"}
            proxy_set_header X-Real-IP $remote_addr;                     # 客户端真实IP:ml-citation{ref="3" data="citationList"}
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 完整代理链路IP:ml-citation{ref="3,8" data="citationList"}
            proxy_set_header X-Forwarded-Proto $scheme;                  # 请求协议（http/https）:ml-citation{ref="3" data="citationList"}
        }

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

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

    server {
        listen            8889;
        listen       [::]:8889;
        server_name  localhost;

        #listen        8889 ssl;
        #listen   [::]:8889 ssl;
        #server_name  localhost;
        #ssl_certificate               cacert.pem;
        #ssl_certificate_key          privkey.pem;

        proxy_set_header X-Forwarded-For $remote_addr;

        location / {
            proxy_pass         http://127.0.0.1:8000;
            proxy_set_header   Host $http_host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host $server_name;
            #proxy_set_header  X-Forwarded-Proto https;
            # used for view/edit office file via Office Online Server
            proxy_read_timeout               1200s;
            client_max_body_size                 0;
            access_log      logs/seahub.access.log;
            error_log        logs/seahub.error.log;
        }

        location /seafhttp {
            rewrite ^/seafhttp(.*)$ $1 break;
            proxy_pass http://127.0.0.1:8082;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            client_max_body_size        0;
            proxy_connect_timeout  36000s;
            proxy_read_timeout     36000s;
            proxy_send_timeout     36000s;
            send_timeout           36000s;
            proxy_request_buffering   off;
        }

        location /media {
            root    seafile/seafile-server-latest/seahub;
        }
    }

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}


rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir rtmp_temp;

rtmp {
    server {
        listen     1935;
        chunk_size 4096;

        application live{
            live                 on;
            gop_cache           off;
            drop_idle_publisher 10s;

            dash on;
            hls  on;
            dash_path /full/path/to/nginx/html/stream/dash;
            hls_path  /full/path/to/nginx/html/stream/hls;
        }
    }
}
