Welcome! Log In Create A New Profile

Advanced

grpc with browser client

Posted by drkbkr 
grpc with browser client
October 09, 2018 01:15PM
Hello,
We're experimenting with grpc and ways to expose those services to clients. I've followed along with the blog post here:
https://www.nginx.com/blog/nginx-1-13-10-grpc/ and gotten the helloworld client to connect to the helloworld server through nginx but now I'm wondering if it's possible to route normal web client traffic to the grpc server and send back a response suitable for a browser. We have a lot of existing web client code (html / javascript, etc) that we'd prefer not to muck with.

Our server is configured like:

server {
listen 80 http2;
listen 443 ssl http2;
server_name 127.0.0.1;

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;

access_log logs/host.access.log main;

location / {
root /usr/share/nginx/html;
index index.html;
}

location /helloworld.Greeter/SayHello {
grpc_pass grpc://127.0.0.1:50051;
}

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

}

The request gets issued using curl:
curl -k -X POST https://127.0.0.1/helloworld.Greeter/SayHello

And the error in the error log:
2018/10/09 11:46:32 [error] 25850#25850: *60 upstream rejected request with error 2 while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, request: "POST /helloworld.Greeter/SayHello HTTP/2.0", upstream: "grpc://127.0.0.1:50051", host: "127.0.0.1"

Other maybe useful information: using nginx 1.14.0 on arch linux. grpc server is the python version of the helloworld server

Any help would be greatly appreciated!

Thanks,
Derek
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 71
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready