GRPC (2): Centos installation NGHTTP2 do GRPC HTTP2 agent

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

1,nghttp2

Compared to the Nginx name, but it is a C llib library. HTTP services can also be done by itself.
can also do proxy server, support SSL.
I've done tests before.
http://blog.csdn.net/freewebsys/article/details/58584294
Because Nginx is not supported for upstream HTTP2 forwarding requests.
And Nginx has no plans to develop this.
And Haproxy is to support TCP proxy. The agreement with HTTP2 is also not supported.
I'm going to do a GRPC gateway later on.
Must be able to support the HTTP2 protocol. But also can proxy grpc.
Looking for a long day to find a NGHTTP2.

2, download and install

Official website:
https://nghttp2.org/
Https://github.com/nghttp2/nghttp2
The official documentation is installed on Ubuntu or Debian.
It can actually be installed on top of CentOS.
Reference:
https://kirk91.github.io/2017/02/22/build-nghttp2-on-centos/
Go directly to the next step.
To install a dependent library:

sudo yum- yGroupinstall"Development Tools"sudo yum- yInstall OpenSSL-develLibxml2-develLibev-develJemalloc-develPython-develwget https://c-ares.haxx.se/download/c-ares-1.12.0.tar.gz-o/tmp/c-ares.tar.gzMkdir- P/tmp/c-aresTar-ZXVF/tmp/c-ares.Tar.Gz- C/tmp/c-ares --Strip-components=1Cd/tmp/c-ares && ./configure--Libdir=/usr/lib64makesudo make Installwget http://www.digip.org/jansson/releases/jansson-2.9.tar.gz-o/tmp/jansson.tar.gzMkdir- P/tmp/janssontar-ZXVF/tmp/jansson.Tar.Gz- C/tmp/jansson--Strip-components=1Cd/tmp/jansson&& ./configure--Libdir=/usr/lib64makemake Checksudo make Install

Install the NGHTTP2 service.

wget https://github.com/nghttp2/nghttp2/releases/download/v1.19.0/nghttp2-1.19.0.tar.gz -O /tmp/nghttp2.tar.gzmkdir -p /tmp/nghttp2tar -zxvf /tmp/nghttp2.tar.gz -C /tmp/nghttp2 --strip-components=1cd /tmp/nghttp2 && ./configure --enable-appmakesudo make install

There is no error that the compilation was successful.

3, start the service

Fewer documents on the Web
Https://nghttp2.org/documentation/package_README.html
Configuration can be configured directly according to proxy.
Https://nghttp2.org/documentation/nghttpx-howto.html
But found a few more pits. Using the command line parameters is not the same as the configuration file.
The result is that the configuration file can be used. Parameter definitions are more bizarre.
I spent an afternoon of time tossing, important understand how to configure.
Nghttpx.conf

Frontend=0.0. 0. 0, the; no-tlsBackend=127.0. 0. 1,50051;/;p Roto=H2backend=127.0. 0. 1,50051;/helloworld.Greeter/;p Roto=H2backend=127.0. 0. 1,50052;/aaa/;p Roto=H2#http2-proxy=Noworkers=TenAccesslog-file=/Data/nghttp/Log/access.LogErrorlog-file=/Data/nghttp/Log/errorlog.Log

First is the frontend configuration, do not use TLS to access the words must be added.
Otherwise, you will need to add key and CRT files, and use HTTPS when you access them.
Backend end, must not add TLS, otherwise will be reported 502 error.
And for backend's GRPC service, be sure to add proto=h2 parameters.
The mandatory agreement is HTTP2. Otherwise 502 error is reported.

4, start the service

nghttpx--confnghttpx.conf

From the Access log look:

10.0.2.2- - [ on/mar/ .:Geneva: in: --0500]"Post/helloworld. Greeter/sayhello HTTP/2 "  $  + "-" "Token=xxxxx grpc-java-netty/1.1.2"10.0.2.2- - [ on/mar/ .:Geneva: in: --0500]"Post/helloworld. Greeter/sayhello HTTP/2 "  $  + "-" "Token=xxxxx grpc-java-netty/1.1.2"10.0.2.2- - [ on/mar/ .:Geneva: in: --0500]"Post/helloworld. Greeter/sayhello HTTP/2 "  $  + "-" "Token=xxxxx grpc-java-netty/1.1.2"10.0.2.2- - [ on/mar/ .:Geneva: in: --0500]"Post/helloworld. Greeter/sayhello HTTP/2 "  $  + "-" "Token=xxxxx grpc-java-netty/1.1.2"10.0.2.2- - [ on/mar/ .:Geneva: in: --0500]"Post/helloworld. Greeter/sayhello HTTP/2 "  $  + "-" "Token=xxxxx grpc-java-netty/1.1.2"10.0.2.2- - [ on/mar/ .:Geneva: in: --0500]"Post/helloworld. Greeter/sayhello HTTP/2 "  $  + "-" "Token=xxxxx grpc-java-netty/1.1.2"

You can see the request.
Which/helloworld. Greeter/sayhello represents the package name, interface name, and method name for GRPC.

5, summary

The text of this text connection is: http://blog.csdn.net/freewebsys/article/details/59112145 not allowed to reprint without the Bo master.
Bo main address is: Http://blog.csdn.net/freewebsys

NGHTTP2 is a good GRPC proxy server that can do simple load balancing.
At the same time keep HTTP2 links.
is a good GRPC gateway solution. The only disadvantage is written in C + +.
If you change it into a privilege, the data-statistic gateway will be a bit more difficult to modify. I am not engaged in C + + development.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.