2

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?

1 Answer 1

2

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.

3
  • Thank you Jenny D for your answer! My problem is that I don't have access to the back end server. The back end server got file that uses $_SERVER['HTTPS'] , and it needs to be on. If I had access to this file, I would make a simple check of the forwarded protocol header, and if it is https, then i would set that variable On. But still my problem is that I don't have access:( And my client don't want to change the settigns, because before that they had an administrator who managed somehow set up it:( Thank you!
    – volf
    Feb 20, 2013 at 10:51
  • Does the backend server speak HTTPS at all? Because if they do, you could use mod_proxy_connect and talk HTTPS to them. Otherwise, if your client doesn't want to change their settings there's not much you can do.
    – Jenny D
    Feb 20, 2013 at 11:02
  • 2 Jenny D: No, the back end server doesn't speak https:( I will try to speak with client regarding changing settings. Thank you for your time and answers. But I will also continue looking for the solution. If I will find something, I will post the solution here. People if you know some kind of solutions for my situation, please help me...
    – volf
    Feb 20, 2013 at 13:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .