Apache reverse proxy forwarding https header

apache-2.2forwardinghttp-headersPROXY

I have successfully installed reverse proxy on Apache. It works like a charm. I'm using it to proxy https request to http. My problem is that I need to forward variable SERVER_HTTPS to my end server, to indicate if person is using ssl connection or just http. I have found one way to do:
I can forward HTTP_X_FORWARDED_PROTO variable and check on end server:

   if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
   $_SERVER['HTTPS']='on'; 

But this variant is not good for me, because I can't edit the end servers scripts. Lets say that I don't even have access to it. But I know how to check if it is forwarded. So, Generally my question is: Is there any way that I can forward this variable? I have seen one more variant, with Rewrite engine , but it didin't work for me and there is no detailed information. Maybe If I will set my server on Nginx + apache this will send this header variable?

Best Answer

The problem is that variables describe the environment of the server receiving the request. When the connection is made to the backend HTTP server it will set its own variables to describe its own environment. You cannot force a server to change its own description of the world it lives in; the best you can do is forward a header that the server can choose to use to change its own environment.

I'm not clear on whether you have access to the backend server configuration. If you do, you may be able to use the SetEnv or SetEnvIf directive there. There's some documentation at the mod_env page at apache.org.