I have endpoint termination setup on my Google Cloud Platform HTTP Load Balancer and HTTPS set as the protocol for communication with my backends.
This means that all requests, HTTP or HTTPS, is HTTPS to apache. The problem with this is that the HTTPS
environment variable is set to on
even when X-Forwarded-Proto
is set to http
.
All of my research and testing only points to the inverse case (setting HTTPS
to on
when X-Forwarded-Proto
is https
via a SetEnvIf X-Forwarded-Proto https HTTPS=on
rule).
But, I need something to unset HTTPS
when X-Forwarded-Proto
is http
.
I've tried setting SSLOptions -StdEnvVars
as well as many combinations of SetEnvIf
, SetEnv
, and UnsetEnv
. Setting it via mod_rewrite is not an option for me (I don't know if it would work anyway). An interesting note about turning off StdEnvVars
is that even when it is off, all the SSL related variables are gone except HTTPS
and I can confirm nothing else is setting it in any of my config files.
Edit:
Some examples of directives I've tried in my server config, vhost, and htaccess:
SetEnvIf X-Forwarded-Proto http HTTPS=Off
SetEnvIf X-Forwarded-Proto http HTTPS=0
SetEnvIf X-Forwarded-Proto http !HTTPS
SetEnv HTTPS Off
SetEnv HTTPS 0
SetEnv HTTPS
UnsetEnv HTTPS
Using these directives with other variables, including tests like foo
works just fine.