Apache – Using ProxyPassReverse with HTTPS

apache-2.2httpsreverse-proxy

I would like to map all traffic on 80 and 443 from foo.com to an internal server: 192.168.1.101.
I have a VirtualHost (Apache 2.2 on Ubuntu) setup as follows (note, I had to break up the hyperlinks below because I am a 'new user'):

<VirtualHost *:80>
  ServerName foo.com
  ServerAlias *.foo.com
  ProxyRequests Off
  ProxyPreserveHost On

  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>

  ProxyPass / http://192.168.1.101/
  ProxyPassReverse / http://192.168.1.101/
</VirtualHost>

And that works great for http traffic. However, I can't seem to do the same thing for https. I have tried:

  • Changing VirtualHost *:80 to * –
    but that doesn't work (I need it
    http->http and https->https)

  • Creating a new VirtualHost entry
    for *:443 that redirects to
    http://192.168.1.101/, but that fails
    as well (browser timeouts)

I did some searching, here and elsewhere, and the closest question I could find was this, but that didn't quite answer it.

Also, just out of curiosity, I tried mapping all ports to https (by changing the two ProxyPass lines from http to https (and removing the :80 from VH), and that didn't work either. How would you do that as well?

Any thoughts?
Thanks in advance.

Best Answer

This used to work for me

<VirtualHost *:443>                                                                                                                                                                        
 ServerName domaine.com
 SSLProxyEngine on                                                                                                                                                                          
 <Location />                                                                                                                                                                               
 ProxyPass https://www.something.com/                                                                                                                                                           
 ProxyPassReverse https://www.something.com/                                                                                                                                                    
 </Location>                                                                                                                                                                                
</VirtualHost>