GithubHelp home page GithubHelp logo

zengqiang2013 / nginx-quic Goto Github PK

View Code? Open in Web Editor NEW

This project forked from evansun922/nginx-quic

0.0 1.0 0.0 15.42 MB

nginx support quic

License: BSD 2-Clause "Simplified" License

Python 0.94% C++ 9.95% C 87.68% XSLT 1.12% Shell 0.02% HTML 0.29%

nginx-quic's Introduction

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.

            python3 mk2gn.py </path/to/nginx> </path/to/chromium/src> <args>

             </path/to/nginx>:                      path of nginx.
             </path/to/chromium/src>:    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:       quic_stream_buffered_size   1048576;
Default:      1048576 
Context:      server
send cache size of quic stream.


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


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


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


Syntax:          quic_idle_network_timeout     time;
Default:         quic_idle_network_timeout     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

nginx-quic's People

Contributors

evansun922 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.