0

We're experimenting with an RPC service (linkerd) that acts as a glue between our microservices – reading off their locations from a local Consul cluster etc. Now Linkerd expects to see the Host header on an incoming request to figure out which service to hit.

In our topology, we have nginx running as the edge which is then supposed to proxy to Linkerd and set the Host header depending on the path.

So a simple configuration we're testing looks like this;

    location /api/v1/services/service-x {
            proxy_set_header Host service-x;
            proxy_pass http://linkerd:4140;
    }

Which is nothing fancy. It matches the paths that are the paths of service-x, then attempts to proxy_pass those requests to linkerd with the name of the service set in the header Linkerd is supposed to receive.

What we're seeing is that the Host header is never set. The service is reachable via Linkerd if I curl -H "Host: service-x" linkerd:4140/some/x/path.

How are we supposed to set headers for upstreams with nginx? Or am I doing something stupid?

Thanks!

Ashesh
  • 224
  • 1
  • 13
  • This is the right way to set `Host` header. What exactly doesn't work? Probably you need to strip `/api/v1/services/service-x` prefix? – Alexey Ten Jul 21 '16 at 11:22

1 Answers1

1

This was actually something I had missed – linkerd supports HTTP/1.1 out of the box and nginx was using 1.0 to forward to the linkerd service. Adding

proxy_http_version 1.1

Fixed the issue for me.

Ashesh
  • 224
  • 1
  • 13