Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#1515 closed defect (invalid)

Can't have multiple and/or non-root locations with grpc_pass

Reported by: mhausenblas@… Owned by:
Priority: major Milestone:
Component: nginx-core Version: 1.13.x
Keywords: Cc:
uname -a: Linux kruiser-76c58747d7-rb85m 4.9.64 #1 SMP Tue Jan 23 23:15:00 UTC 2018 x86_64 Linux
nginx -V: nginx version: nginx/1.13.10
built by gcc 6.4.0 (Alpine 6.4.0)
built with OpenSSL 1.0.2n 7 Dec 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-threads --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module--with-stream_realip_module --with-stream_geoip_module=dynamic --with-http_slice_module --with-mail --with-mail_ssl_module --with-compat --with-file-aio --with-http_v2_module

Description

NGINX reverse-proxy gRPC config works fine for a single location with path / but not for say /yages.Echo or a combination of both.

See overall setup in https://github.com/mhausenblas/kruiser/blob/master/how-does-it-work.md#setup

See full NGINX config in https://github.com/mhausenblas/kruiser/blob/master/static/kruiser.yaml#L10

Output is as follows:

$ grpcurl --plaintext kruiser:8080 yages.Echo.Ping
{
  "text": "pong"
}

$ grpcurl --plaintext kruiser:8080/yages.Echo yages.Echo.Ping
Failed to dial target host "kruiser:8080/yages.Echo": dial tcp: address tcp/8080/yages.Echo: unknown port

I've tried a number of config options from the test cases, nothing helped.

Change History (6)

comment:1 by Maxim Dounin, 6 years ago

Resolution: invalid
Status: newclosed

The message in question is from grpcurl, and it basically says that address kruiser:8080/yages.Echo you've tried to use is invalid. That's expected: as per gRPC protocol you cannot use arbitrary URL prefixes in gRPC services, rather, you specify host and port only, like in "kruiser:8080", and the rest of the URL is strictly defined by the service name and the method used.

You still can use locations in nginx to direct different gRPC services and methods to different upstream servers. And this is what your configuration actually does, though you use the same upstream server for both location / and location /yages.Echo.

comment:2 by mhausenblas@…, 6 years ago

Thanks for looking into it, will test and try to verify what you said above.

comment:3 by mhausenblas@…, 6 years ago

Resolution: invalid
Status: closedreopened

Still doesn't work, even when implementing your advice, see https://github.com/mhausenblas/kruiser/blob/master/static/kruiser.yaml#L16 for the current setup. Now the error is (same for the echo service):

Error invoking method "helloworld.Greeter": failed to query for service descriptor "helloworld": rpcerror: code = Internal desc = transport: received the unexpected content-type "text/html"

comment:4 by Maxim Dounin, 6 years ago

Resolution: invalid
Status: reopenedclosed

In your new configuration you fail to proxy reflection service anywhere, and grpcurl uses this service by default.

Please avoid abusing Trac for questions on how to configure things properly, it is to report bugs. If you have further questions, please use support options available. Also, it might be a good idea to look into nginx logs before asking anything - nginx logs usually contain enough information to understand what goes wrong.

comment:5 by mhausenblas@…, 6 years ago

Reflexion is enabled AFAICT (https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_server/main.go#L53) and the logs are empty. Thanks for your help. Since I can't resolve it, will drop NGINX backend support.

Version 0, edited 6 years ago by mhausenblas@… (next)

comment:6 by Maxim Dounin, 6 years ago

As I already wrote above, the problem is that you fail to proxy the reflection service anywhere in your configuration. You only have locations to proxy /yages.Echo and /helloworld.Greeter, but requests to the reflection service will use /grpc.reflection.v1alpha.ServerReflection.

If you have further questions, please use support options available.

Note: See TracTickets for help on using tickets.