Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google cloud load balancer custom http header is missing

While using Google Cloud HTTPS Load Balancer we hit the following bug. Couldn't find any information on it.

We have a custom http header in our request: X-<Company name>-abcde. If we are working directly against the server all is good, but once we are working through the load balancer, than our custom header is missing. We didn't find any reference in the documentation that there is a need to white list our headers or something like that.

Why my custom header is not being transferred to my backend server while working through Google Cloud Load Balancer? And how to make it work?

Thanks

like image 335
nheimann1 Avatar asked Jan 25 '17 10:01

nheimann1


People also ask

Can I add custom header to HTTP request?

In the Home pane, double-click HTTP Response Headers. In the HTTP Response Headers pane, click Add... in the Actions pane. In the Add Custom HTTP Response Header dialog box, set the name and value for your custom header, and then click OK.

How do I set up HTTP headers?

Select the web site where you want to add the custom HTTP response header. In the web site pane, double-click HTTP Response Headers in the IIS section. In the actions pane, select Add. In the Name box, type the custom HTTP header name.

What is HTTP request custom header?

Custom HTTP headers can be used to filter requests or specify a value for the Accept header. Some endpoints employ custom HTTP headers to filter data returned by a GET or POST request.


1 Answers

Data

After a lot of testing, these are the results I've come up with:

  1. The Google Cloud HTTPS Load Balancer does transfer custom HTTP headers to the backend service.
  2. However, it changes them to lower-case.

So, in your case, X-Custom-Header is transformed to x-custom-header.

Solution

  1. Simply change your code to read the lower-case version of your custom HTTP header. This is a simple fix, but one which may not be supported in the long-term by Google (there's not a word on this in Google's documentation so it's subject to change with no notice).
  2. Petition Google to change this idiosyncratic behaviour or at the very least mention it clearly in their documentation.

A little extra

As far as I know, the RFC 2047 which specified the X- prefix for custom HTTP headers and propagated the pseudo-standard of a capital letter for each word has been deprecated and replaced by RFC 6648 which recommends against the X- prefix in general and mentions nothing regarding the rest of the words in the custom HTTP header key name. If I were Google, I would change this behaviour to pass custom HTTP headers as is and let developers deal with the strings as they've set them.

like image 121
SimpleAnecdote Avatar answered Nov 26 '22 19:11

SimpleAnecdote