I would like to use only HTTP 1.0 on a certain VirtualHost in Apache. The reason for doing so is that I use CloudFlare, and my apps requires the Content-Length header in the HTTP response. However, CloudFlare only forwards the Content-Length header if HTTP 1.0 is used as the protocol (refer to this support ticket: https://support.cloudflare.com/hc/en-us/requests/527063).

My question here is how do I easily set up a certain VirtualHost in Apache to accomplish this (force the use of HTTP 1.0 as the protocol)? Do I use something like SetEnv in a sites-available config file? Or perhaps, I use the HTTP 1.1 protocol, but send HTTP 1.0 as the protocol in the header?



From https://www.safaribooksonline.com/library/view/apache-the-definitive/0596002033/re249.html here are examples of using the force-response-1.0 variable with BrowserMatch.

# The following directives modify normal HTTP response behavior.
# The first directive disables keepalive for Netscape 2.x and browsers that
# spoof it. There are known problems with these browser implementations.
# The second directive is for Microsoft Internet Explorer 4.0b2
# which has a broken HTTP/1.1 implementation and does not properly
# support keepalive when it is used on 301 or 302 (redirect) responses.
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0

# The following directive disables HTTP/1.1 responses to browsers which
# are in violation of the HTTP/1.0 spec by not being able to grok a
# basic 1.1 response.
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0

with official docs at http://httpd.apache.org/docs/2.4/env.html#special which state


This forces an HTTP/1.0 response to clients making an HTTP/1.0 request. It was originally implemented as a result of a problem with AOL's proxies. Some HTTP/1.0 clients may not behave correctly when given an HTTP/1.1 response, and this can be used to interoperate with them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.