nginx-quic

by evansun922

evansun922 / nginx-quic

nginx support quic

163 Stars 52 Forks Last release: Not found BSD 2-Clause "Simplified" License 80 Commits 5 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Help us to improve the Nginx-Quic

Begin to Nginx-Quic

Why nginx-quic

The purpose of this project is to make nginx support quic and keep the original functions of nginx unchanged. this project requires nignx and chromium source code

At present, this project had only been tested under the Linux kernel and epoll network, which requires Linux kernel 4.18.20-1. El6. Elrepo. X86_64 and above, currently, nginx-quic only test on 1.14.2 and 1.16.0 version of nginx, and nginx-1.16.0 and above is recommended.

We implemented a set of "RTMP over quic" solutions, using nginx-rtmp-module for the server and srs-librtmp for the client, this srs-librtmp-quic project links is https://github.com/sonysuqin/SrsQuic.

There is a compiled nginx-quic in bin,you can run it on centos, redhat, ubuntu, etc, the test nginx-quic's --prefix=/opt/nginx/.

中文版文档

Compile

The compilation step of nginx-quic is quite complicated, so I will try to explain it in detail. In addition, you can read some gn documents to learn it.

The compilation needs to be carried out under ubuntu 14, which can be compiled using virtual machine. please see the official website of chromium for Linux system requirements. - download chromium, see: the official website of chromium. - download nginx source code. - run mk2gn.py, The parameters of the script are as follows: ```
python3 mk2gn.py

         :                      path of nginx.
         :    path of chromium/src.
         < args>:                                          when configure nginx, the parameters required to configure.                 
- if you need  to build rtmp-quic,  you can add "--add-module=/path/to/nginx-quic/quic_rtmp/nginx-rtmp-module".
- cd /path/to/chromium/src, and run __gn gen out/Release --args="is_component_build=false is_debug=false"__.
- run __ninja -C out/Release  nginx__.


Mark:

  • If you need to define macros or add some libraries, you can manually modify the chromium/src/net/BUILD.gn about the configuration of nginx.
                        executable("nginx") {
                      sources = [
                          # the source file .c or .cc,  you don't usually modify it.
                      ]
                      include_dirs = [
                          #add the directory dir to the list of directories to be searched for header files during preprocessing.
                      ]
                      lib_dirs = [
                          #  add directory dir to the list of directories to be searched for libraries.
                      ]
                      libs = [
                          # dynamic library: pthread or static library: /path/xxx.a
                      ]
                      cflags_c = [
                          # compile option flags
                          "-D_FORTIFY_SOURCE=2",
                          "-DTCP_FASTOPEN=23",
                          "-DNDK_SET_VAR",
                      ]
                  }
- All of static libraries used by nginx, which should be compiled with the flag "-fPIC".
  • no use openssl, nginx-quic use boringssl of chromium.

  • nginx-quic Configuration

    Example Configuration

    > http { > > ... > > server { > listen 443 quic reuseport sndbuf=1048576 rcvbuf=1048576; >
    > ssl_certificate ssl/tv.test.com.crt; > ssl_certificate_key ssl/tv.test.com.pkcs8; > > > > ... > }

    Directives

    Syntax: listen quic; Default: listen *:80 | *:8000 quic; Context: server Example: listen 443 quic reuseport sndbuf=1048576 rcvbuf=1048576; add flag "quic" of "listen" for using quic , when you use flag "quic", be sure to bring the flag "reuseport" and you can not used "ssl" or "http2" at the same time.

    Syntax: quicstreambuffered_size 1048576; Default: 1048576 Context: server send cache size of quic stream.

    Syntax: quicbbr on | off; Default: quicbbr off; Context: http, server, location enable bbr of quic

    Syntax: quicietfdraft on | off; Default: quicietfdraft off; Context: http, server, location use the IETF draft version.

    Syntax: quicflushinterval number; Default: quicflushinterval 40; Context: http, server, location the buffered of sendmmsg is refreshed every "number" milliseconds.

    Syntax: quicidlenetworktimeout time; Default: quicidlenetworktimeout 10m; Context: http, server, location Idle network timeout in seconds. ```


    nginx-rtmp Configuration

    Example Configuration

          rtmp {
    
    
          ...
    
          server {
    
                     listen         1935 so_keepalive=on;
                     listen         1935 quic reuseport;
    
                     ssl_certificate                ssl/tv.test.com.crt;
                     ssl_certificate_key       ssl/tv.test.com.key; 
    
                   application live {
                             live on;
                             idle_streams        off;
                             drop_idle_publisher 1800s;
                             sync                1s;
                             wait_key            on;
                             wait_video          on;    
                    }
          }

    }

    Directives

    Syntax:                listen   quic;
    Default:               listen   *:80 | *:8000 quic;
    Context:              server
    Example:             listen       1935 quic reuseport sndbuf=1048576 rcvbuf=1048576;
    add flag "quic" of "listen" for using quic ,  when you use flag "quic", be sure to bring the flag "reuseport" and you can not used "ssl" or "http2" at the same time.
    
    
    

    Syntax: quic_stream_buffered_size 1048576; Default: 1048576 Context: server send cache size of quic stream.

    Syntax: quic_flush_interval number; Default: quic_flush_interval 40; Context: http, server, location the buffered of sendmmsg is refreshed every "number" milliseconds.

    Copyright

    • SOHU-TV, Inc.

    Author

    We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.