# configuration file /etc/nginx/nginx.conf:
#######################################################################
#
# This is the main Nginx configuration file.  
#
# More information about the configuration options is available on 
#   * the English wiki - http://wiki.nginx.org/Main
#   * the Russian documentation - http://sysoev.ru/nginx/
#
#######################################################################

#----------------------------------------------------------------------
# Main Module - directives that cover basic functionality
#
#   http://wiki.nginx.org/NginxHttpMainModule
#
#----------------------------------------------------------------------

user              nginx;
worker_processes  auto;
worker_rlimit_nofile 245760;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;


load_module modules/ngx_http_vod_module.so;


#----------------------------------------------------------------------
# Events Module 
#
#   http://wiki.nginx.org/NginxHttpEventsModule
#
#----------------------------------------------------------------------

events {
    worker_connections  131070;
    multi_accept on;
    use epoll;
}


#----------------------------------------------------------------------
# HTTP Core Module
#
#   http://wiki.nginx.org/NginxHttpCoreModule 
#
#----------------------------------------------------------------------

http {
    include       /etc/nginx/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 account '$body_bytes_sent $request_time';
    log_format debugunmasked 'Unmasked $body_bytes_sent $request_time $msec $remote_addr $arg_st $uri $arg_e - $secure_link $status "$http_referer" "$http_user_agent"';
    log_format debugmasked 'Masked $body_bytes_sent $request_time $msec $remote_addr $status $request_filename';
    access_log  off;

    sendfile        on;
    tcp_nodelay on;
    reset_timedout_connection on;
    client_body_timeout 10;
    send_timeout 5;

    keepalive_disable none;
    keepalive_timeout  65;

    #gzip  on;


    upstream main {
        server unix:/var/run/php-fpm.sock;
        keepalive 32;
    }
    
    #
    # The default server
    #
    server {
        listen       81;
        listen       80;
        listen       443 ssl http2;

        ssl_certificate /etc/nginx/cert.pem;
        ssl_certificate_key /etc/nginx/cert.key;
        ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers         HIGH:!aNULL:!MD5;


        server_name  _;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        root /somewhere;


        open_file_cache          max=200000 inactive=200s;
        open_file_cache_valid    300s;
        open_file_cache_min_uses 2;

        aio on;
        vod_metadata_cache metadata_cache 4096m;
        vod_response_cache response_cache 256m;




        location /foo/ {
            access_log /var/log/nginx/stats.log.norotate debugmasked;
            alias /somewhere/;

                fastcgi_pass main;
                fastcgi_keep_conn on;
                fastcgi_param  SCRIPT_FILENAME    /somewhere/something;
                fastcgi_param  QUERY_STRING       $query_string;
                fastcgi_param  REQUEST_METHOD     $request_method;
                fastcgi_param  CONTENT_TYPE       $content_type;
                fastcgi_param  CONTENT_LENGTH     $content_length;
                fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
                fastcgi_param  REQUEST_URI        $request_uri;
                fastcgi_param  DOCUMENT_URI       $document_uri;
                fastcgi_param  DOCUMENT_ROOT      /somewhere;
                fastcgi_param  SERVER_PROTOCOL    $server_protocol;
                fastcgi_param  HTTPS              $https if_not_empty;
                fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
                fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
                fastcgi_param  REMOTE_ADDR        $remote_addr;
                fastcgi_param  REMOTE_PORT        $remote_port;
                fastcgi_param  SERVER_ADDR        $server_addr;
                fastcgi_param  SERVER_PORT        $server_port;
                fastcgi_param  SERVER_NAME        $server_name;
                fastcgi_param  REDIRECT_STATUS    200;
                gzip on;
                gzip_types application/vnd.apple.mpegurl video/f4m application/dash+xml text/xml;
                if ( $http_origin ~* (https?://(.+\.)?(fooobarr)$) ) {
                        add_header Access-Control-Allow-Headers "origin,range,accept-encoding,referer" always;
                        add_header Access-Control-Expose-Headers "Server,range,Content-Length,Content-Range" always;
                        add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS" always;
                        add_header Access-Control-Allow-Origin "$http_origin" always;
                }
        }

        location /bar/ {
            internal;
            access_log /var/log/nginx/stats.log.norotate debugmasked;
            alias /somewhere/;
            vod hls;
            vod_mode local;
            #vod_manifest_segment_durations_mode accurate;
            vod_align_segments_to_key_frames on;
            vod_bootstrap_segment_durations 5000;
            vod_segment_duration 10000;

            vod_hls_mpegts_interleave_frames on;
            vod_hls_mpegts_align_frames on;


            add_header Cache-Control "max-age=0, no-cache, no-store";
            if ( $http_origin ~* (https?://(.+\.)?(fooobarr)$) ) {
                        add_header Access-Control-Allow-Headers "origin,range,accept-encoding,referer" always;
                        add_header Access-Control-Expose-Headers "Server,range,Content-Length,Content-Range" always;
                        add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS" always;
                        add_header Access-Control-Allow-Origin "$http_origin" always;
            }
        }



        location /baz/ {
            access_log /var/log/nginx/stats.log.norotate debugmasked;
            alias /somewhere/;
            vod hls;
            vod_mode local;
            #vod_manifest_segment_durations_mode accurate;
            vod_align_segments_to_key_frames on;
            vod_bootstrap_segment_durations 5000;
            vod_segment_duration 10000;

            vod_hls_mpegts_interleave_frames on;
            vod_hls_mpegts_align_frames on;

            allow 127.0.0.1;
            deny all;

            add_header Cache-Control "max-age=0, no-cache, no-store";

        }

        location /boo/ {
                fastcgi_pass main;
                fastcgi_param  SCRIPT_FILENAME    /somewhere/somehting;
                fastcgi_param  QUERY_STRING       $query_string;
                fastcgi_param  REQUEST_METHOD     $request_method;
                fastcgi_param  CONTENT_TYPE       $content_type;
                fastcgi_param  CONTENT_LENGTH     $content_length;
                fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
                fastcgi_param  REQUEST_URI        $request_uri;
                fastcgi_param  DOCUMENT_URI       $document_uri;
                fastcgi_param  DOCUMENT_ROOT      /somewhere;
                fastcgi_param  SERVER_PROTOCOL    $server_protocol;
                fastcgi_param  HTTPS              $https if_not_empty;
                fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
                fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
                fastcgi_param  REMOTE_ADDR        $remote_addr;
                fastcgi_param  REMOTE_PORT        $remote_port;
                fastcgi_param  SERVER_ADDR        $server_addr;
                fastcgi_param  SERVER_PORT        $server_port;
                fastcgi_param  SERVER_NAME        $server_name;
                fastcgi_param  REDIRECT_STATUS    200;
                access_log /var/log/nginx/stats.log.norotate debugmasked;
        }

        location /bee/ {
                alias /somewhere/;
                internal;
                access_log /var/log/nginx/stats.log.norotate debugmasked;
        }



        location /fee/ {
                root /somewhere;
                default_type image/jpeg;
                try_files $uri @tee;
                expires 365d;
                access_log off;
        }

        location @tee {
                fastcgi_pass main;
                fastcgi_param  SCRIPT_FILENAME    /somewhere/something;
                fastcgi_param  QUERY_STRING       $query_string;
                fastcgi_param  REQUEST_METHOD     $request_method;
                fastcgi_param  CONTENT_TYPE       $content_type;
                fastcgi_param  CONTENT_LENGTH     $content_length;
                fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
                fastcgi_param  REQUEST_URI        $request_uri;
                fastcgi_param  DOCUMENT_URI       $document_uri;
                fastcgi_param  DOCUMENT_ROOT      /somewhere;
                fastcgi_param  SERVER_PROTOCOL    $server_protocol;
                fastcgi_param  HTTPS              $https if_not_empty;
                fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
                fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
                fastcgi_param  REMOTE_ADDR        $remote_addr;
                fastcgi_param  REMOTE_PORT        $remote_port;
                fastcgi_param  SERVER_ADDR        $server_addr;
                fastcgi_param  SERVER_PORT        $server_port;
                fastcgi_param  SERVER_NAME        $server_name;
                fastcgi_param  REDIRECT_STATUS    200;
                access_log off;
        }

        location /tii {
                alias /somewhere/tii;
                internal;
                expires 365d;
                access_log off;
        }

        location = /too {
            add_header Access-Control-Allow-Headers "origin,range,accept-encoding,referer";
            add_header Access-Control-Expose-Headers "Server,range,Content-Length,Content-Range";
            add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS";
            add_header Access-Control-Allow-Origin "*";
            add_header Cache-Control "max-age=0, no-cache, no-store";
            access_log off;
        }

        location /server-status {
                stub_status on;
                access_log   off;
                allow 127.0.0.1;
                deny all;
        }

        location /vod-status {
                vod_status;
                access_log   off;
                allow 127.0.0.1;
                deny all;
        }


    }

    server {
        listen       85;
        location / {
                root /somewhere/;
                dav_methods  PUT DELETE MKCOL COPY MOVE;
                create_full_put_path   on;
                dav_access             group:rw  all:r;
                access_log off;
        }
        location = /asdad {
                alias /asdads;
                access_log off;
        }
   }



}


# configuration file /etc/nginx/mime.types:
types {
    text/html                             html htm shtml;
    text/css                              css;
    text/xml                              xml;
    image/gif                             gif;
    image/jpeg                            jpeg jpg;
    application/x-javascript              js;
    application/atom+xml                  atom;
    application/rss+xml                   rss;

    text/mathml                           mml;
    text/plain                            txt;
    text/vnd.sun.j2me.app-descriptor      jad;
    text/vnd.wap.wml                      wml;
    text/x-component                      htc;

    image/png                             png;
    image/tiff                            tif tiff;
    image/vnd.wap.wbmp                    wbmp;
    image/x-icon                          ico;
    image/x-jng                           jng;
    image/x-ms-bmp                        bmp;
    image/svg+xml                         svg;

    application/java-archive              jar war ear;
    application/mac-binhex40              hqx;
    application/msword                    doc;
    application/pdf                       pdf;
    application/postscript                ps eps ai;
    application/rtf                       rtf;
    application/vnd.ms-excel              xls;
    application/vnd.ms-powerpoint         ppt;
    application/vnd.wap.wmlc              wmlc;
    application/vnd.google-earth.kml+xml  kml;
    application/vnd.google-earth.kmz      kmz;
    application/x-7z-compressed           7z;
    application/x-cocoa                   cco;
    application/x-java-archive-diff       jardiff;
    application/x-java-jnlp-file          jnlp;
    application/x-makeself                run;
    application/x-perl                    pl pm;
    application/x-pilot                   prc pdb;
    application/x-rar-compressed          rar;
    application/x-redhat-package-manager  rpm;
    application/x-sea                     sea;
    application/x-shockwave-flash         swf;
    application/x-stuffit                 sit;
    application/x-tcl                     tcl tk;
    application/x-x509-ca-cert            der pem crt;
    application/x-xpinstall               xpi;
    application/xhtml+xml                 xhtml;
    application/zip                       zip;

    application/octet-stream              bin exe dll;
    application/octet-stream              deb;
    application/octet-stream              dmg;
    application/octet-stream              eot;
    application/octet-stream              iso img;
    application/octet-stream              msi msp msm;

    audio/midi                            mid midi kar;
    audio/mpeg                            mp3;
    audio/ogg                             ogg;
    audio/x-realaudio                     ra;

    video/3gpp                            3gpp 3gp;
    video/mpeg                            mpeg mpg;
    video/mp4                             mp4;
    video/quicktime                       mov;
    video/x-flv                           flv;
    video/x-mng                           mng;
    video/x-ms-asf                        asx asf;
    video/x-ms-wmv                        wmv;
    video/x-msvideo                       avi;
}



