title: Web application behind reverse proxy - how do I handle SSL?
body: <p>I have a public Apache server which needs to proxy to an internal Apache server (for SVN access). What I'd like to have is:</p>
  
  <pre><code>User  ---[HTTPS]---&gt;  Web Server  ---[HTTP]---&gt;  SVN Server
  </code></pre>
  
  <p>I'm not too familiar with SSL handling, so I'd like some opinions on this approach. Is this an ok model; should I be using SSL everywhere, etc. </p>
  
  <p>My approach works for the most part, but fails when rewriting redirects back to HTTPS. If a user goes to</p>
  
  <pre><code>    https://acme.web.mcx/svn (no trailing '/')
  </code></pre>
  
  <p>they are redirected by the SVN server to </p>
  
  <pre><code>    http://acme.web.mcx/svn/ (almost there!) 
  </code></pre>
  
  <p>Here's my config for the Web Server (Proxying server):</p>
  
  <pre><code>&lt;VirtualHost *:443&gt;
      ServerAdmin me@admin.com
      ServerAlias *.web.mcx www.web.mcx web.mcx
  
      DocumentRoot /server/web/app/webroot
      ErrorLog logs/web-error_log
      CustomLog logs/web-access_log common
  
      RewriteEngine On
  
      RewriteCond %{HTTP_HOST} !^www\.web\.mcx$ [NC]
      RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.web\.mcx$ [NC]
      RewriteRule ^/svn(.*) http://db.mcx/svn$1 [P]
      ProxyPassReverse /svn http://db.mcx/svn
      ProxyPreserveHost on
  
      SSLEngine on
      SSLCertificateFile      /etc/httpd/ssl/server.crt
      SSLCertificateKeyFile   /etc/httpd/ssl/server.key
      SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
  
      ProxyRequests Off
      &lt;Proxy *&gt;
          Order deny,allow
          Allow from all
      &lt;/Proxy&gt;
      ProxyVia On
  
  &lt;Location /svn/&gt;
      &lt;Limit OPTIONS PROPFIND GET REPORT MKACTIVITY PROPPATCH PUT CHECKOUT MKCOL MOVE COPY DELETE LOCK UNLOCK MERGE&gt;
          Order Deny,Allow
          Allow from all
          Satisfy Any
      &lt;/Limit&gt;
  &lt;/Location&gt;
  </code></pre>
  
  <p></p>