I have a simple rails application
(browser) -> (nginx latest; proxy_pass) -> rails (latest)
How do I configure nginx to notify rails that nginx received an HTTP/2 request via a different header IE: my_"http_version = 2.0"? proxy_pass communicates with rails via HTTP 1.1 and I want to know if the original request was http/2.
Thank you!
This is similar to what the X-Forwarded-For
and X-Forwarded-Proto
headers are used for, but there not a standard header used to communicate the HTTP protocol version to the backend. I recommend using this:
proxy_set_header X-Forwarded-Proto-Version $http2;
The $http2
variables comes from ngx_http_v2_module which I presume you are using with Nginx to server HTTP/2.
The difference between $http2
and $server_protocol
is that $http2
works more like a boolean, appearing blank if the HTTP/1 protocol was used. $server_protocol
will contain values like "HTTP/1.1" or "HTTP/2.0", so it could also be a good choice depending on your needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With