Ssl – Wrong redirection in ProxyPass from http to https

apache-2.2proxypassssl

This is the scenario:

I have got a linux server accesible only by one url (because the server is a virtual machine in a vpn):

url: http://foo.bar.com

I have got several web apps accessible in this way:

foo.bar.com/java_app => java wep app installed in a tomcat

foo.bar.com/webpage => webpage installed in apache server

  • Linux server has got an apache2 server which allow me to use several configuration files to create virtual hosts to do the previous issue:

Note: myhost => localhost

ProxyPreserverHost On

<VirtualHost *:80>
   ServerName foo.bar.com
   DocumentRoot /var/www/webpage
   JkMountCopy On
   SSLProxyEngine On

   ProxyPass /java_app http://myhost:8080/java_app
   ProxyPassReseverse /java_app http://myhost:8080/java_app

   #This uses the DocumentRoot
   ProxyPass /webpage http://myhost:80/
   ProxyPassReseverse /webpage http://myhost:80/

</VirtualHost>

The problem is that I have got another software in node.js accessible internally trough this url:

   https://myhost:8061. (a webpage too).

The solution could be adding theses lines:

   ProxyPass /ssl_app https://myhost:8061/
   ProxyPassReseverse /ssl_app https://myhost:8061/

But this fails. The problem is that the files (sources) of the webpage (js, css, other files) are not load properly, accordingly the web app too. (Firefox)

For example inside the "foo.bar.com/ssl_app" I can see the urls of the sources and those must be in this way:

foo.bar.com/ssl_app/js/one.js
foo.bar.com/ssl_app/js/two.js
foo.bar.com/ssl_app/css/css.js

However I obtain this way:

foo.bar.com/js/one.js
foo.bar.com/js/two.js
foo.bar.com/css/css.js

(redirection of foo.bar.com/ssl_app => foo.bar.com/)

Obviously the web app does not work.

Thus, if i put foo.bar.com/css/css.js directly, the file is showed properly.

log details:

*** File does not exist: /var/www/webpage/lib, refere http://foo.bar.com/ssl_app 

I think that this is for DocumentRoot (/var/www/webpage/), but how can i create a new VirtualHost with the same ServerName?

Any could say me what can I look in the apache config?

Thank you.

Best Answer

You seem to asume that ProxyPassReverse also modifies URLs in the content delivered by the backend. This is not correct. ProxyPassReverse will only be used when your backend server (your "ssl_app") sends a redirect. Content itself is not touched.

You have several options:

  • Modify your "ssl_app" so it uses the correct base URL for it's resources. This is the best solution.
  • Use mod_proxy_html to modify the html served by the backend before you forward it to the client.