title: Redirect a HTTP page to HTTPS with ProxyPass to Tomcat server
body: <p>So I have a tomcat server running on port 8080, and an apache server running on ports 80 and 443. I can get the whole website to redirect to https by using these virtual hosts:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      Redirect permanent / https://localhost
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost _default_:443&gt;
      SSLEngine on
      SSLCertificateFile /etc/httpd/crt/localhost.crt
      SSLCertificateKeyFile /etc/httpd/crt/localhost.key
      ProxyRequests off
      ProxyPreserveHost on
      ProxyPass / http://localhost:8080/
      ProxyPassReverse / http://localhost:8080/
      ProxyPass /catdapp http://localhost:8080/
      ProxyPassReverse /catdapp http://localhost:8080/
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>However, am trying to get it so that it only redirects to https when the url is <code>localhost/#/login</code> or <code>localhost/catdapp/#/login</code></p>
  
  <p>I have tried the following:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      Redirect permanent /#/login https://localhost/#/login
      Redirect permanent /catdapp/#/login https://localhost/#/login
      ProxyRequests off
      ProxyPreserveHost on
      ProxyPass /#/login !
      ProxyPass /catdapp/#/login !
      ProxyPass / http://localhost:8080/
      ProxyPassReverse / http://localhost:8080/
      ProxyPass /catdapp http://localhost:8080/
      ProxyPassReverse /catdapp http://localhost:8080/
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Which didnt work, the console showed it was retrieving <code>http://localhost/catdapp/partials/login.html</code> so I tried changing it to this:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      Redirect permanent /catdapp/partials/login.html https://localhost/catdapp/partials/login.html
      ProxyRequests off
      ProxyPreserveHost on
      ProxyPass /catdapp/partials/login.html !
      ProxyPass / http://localhost:8080/
      ProxyPassReverse / http://localhost:8080/
      ProxyPass /catdapp http://localhost:8080/
      ProxyPassReverse /catdapp http://localhost:8080/
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Which then results in the firefox console outputting two errors:</p>
  
  <pre><code>GET http://localhost/catdapp/partials/login.html 301 Moved Permanently
  GET https://localhost/catdapp/partials/login.html 200 OK
  </code></pre>
  
  <p>The apache access log shows:</p>
  
  <pre><code>"GET /catdapp/partials/login.html HTTP/1.1" 301 328 "http://localhost" "Mozilla/5.0 (X11; Linux x84_64; rv:38.0) Gecko/20100101 Firefox/38.0"
  "GET /catdapp/partials/login.html HTTP/1.1" 200 2054 "http://localhost" "Mozilla/5.0 (X11; Linux x84_64; rv:38.0) Gecko/20100101 Firefox/38.0"
  </code></pre>
  
  <p>Any ideas?</p>