# Traefik 2.0: Route GRPC Request based on url

**URL:** <https://community.traefik.io/t/traefik-2-0-route-grpc-request-based-on-url/1798>\
**Category:** Traefik v2\
**Tags:** file\
**Created:** [September 23, 2019, 8:45am UTC](https://community.traefik.io/t/traefik-2-0-route-grpc-request-based-on-url/1798 "2019-09-23T08:45:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![einali](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/einali/32/1083_2.png) [@einali](https://community.traefik.io/u/einali)\
**Post date:** [September 23, 2019, 8:45am UTC](https://community.traefik.io/t/traefik-2-0-route-grpc-request-based-on-url/1798/1 "2019-09-23T08:45:41Z")

</div>

Hi every body  
i have suggestion for routing gRPC requests in V2.0  
i reported it as [issue](https://github.com/containous/traefik/issues/5444)  
Please check it.  
Thanks in advance.

can route gRPC request for variable urls  
for instance :  
[example.com/service1](http://example.com/service1) for invoke service1  
[example.com/service2](http://example.com/service2) for invoke service2

in current implementation for example this proto

```auto
syntax = "proto3";

option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
option objc_class_prefix = "HLW";

package helloworld;

// The greeting service definition.
service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {}
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings
message HelloReply {
  string message = 1;
}

```

its better to be called by url: **[example.com/v1/greaters/hello\_world](http://example.com/v1/greaters/hello_world)**

For this proto every request will have attributes like :  
host: [example.com/hello/world](http://example.com/hello/world)  
url path : /helloworld.Greeter/SayHello

as in docs [available matchers](https://docs.traefik.io/routing/routers/) for this scenario are

1. host, HostRegexp
2. Path, PathPrefix

HostRegexp can be used for segregate urls but there is a problem with this approach.

traefik use containous fork on gorilla/mux and in  
pkg/mod/github.com/containous/mux@v0.0.0-20181024131434-c33f32e26898/regexp.go:308

```auto
// getHost tries its best to return the request host.
func getHost(r *http.Request) string {
	if r.URL.IsAbs() {
		return r.URL.Host
	}
	host := r.Host
	// Slice off any port information.
	if i := strings.Index(host, ":"); i != -1 {
		host = host[:i]
	}
	return host

}

```

urls after colon : will be truncated before check regexp.  
My suggestion is use other option for check whole url for routing rule.  
something like grpc url or just Url and UrlRegexP.  
BTW: In gRPC request host variable holds host and path and name Host for url is somehow misleading.

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [September 23, 2019, 8:52am UTC](https://community.traefik.io/t/traefik-2-0-route-grpc-request-based-on-url/1798/2 "2019-09-23T08:52:44Z")

</div>

Hello,

You just need to combined `Host` and `Path`:

```auto
Host(`example.com`) && Path(`/hello/world`)

```
