1 Reply Latest reply on Sep 11, 2009 2:42 AM by Jean-Frederic Clere

    mod_cluster/apache vhosts: bug when using mod_rewrite?

    Robert Davidson Newbie

      Hi all,

      Fairly new to the mod_cluster nightmare, but here goes.

      Using: Apache 2.2.11, mod_cluster 1.0.2.GA. Both Apache and the Apache mod_cluster modules are compiled by myself.

      The problem I've got is this. I've got various virtual hosts configured in Apache. The first virtual host is bound to the machines main IP, and is basically doing nothing more than rewriting URLs and then proxying them to a secondary virtual host entry (bound to 127.0.0.1:80) which is basically just a container that says ProxyPass / balancer://mybal/

      The first virtual host also needs to be able to serve some local content from /var/www/html. So this is basically how its configured:

      <VirtualHost 10.1.1.1:80>
       ServerName myserver.internal
      
       DocumentRoot /var/www/html
      
       RewriteEngine On
      
       # This is mandatory to prevent 503 errors when serving local content.
       ProxyPass ^/MOD_CLUSTER_HAS_A_BUG !
      
       RewriteRule ^/error-pages/.* - [L]
       RewriteRule ^/assets/.* - [L]
      
       # This does not make a loop. myserver.internal is aliased to 127.0.0.1
       # in /etc/hosts
       RewriteRule /(.*) http://myserver.internal/$1 [P,L]
      </VirtualHost>
      
      <VirtualHost 127.0.0.1:80>
       ServerName myserver.internal
       ProxyPass / balancer://mybal/
      </VirtualHost>
      


      So thats a cut-down version of the current config. It seems that without the ProxyPass in the first virtual host, I'll get a 503 error IF AND ONLY IF 1 or more JBossAS servers have registered with mod_cluster and I try to access local content, such as something under http://myserver.internal/error-pages/

      The reason for this weird config is because rewrites don't seem to work correctly with ProxyPass / balancer://mybal at the end of the VirtualHost. So to work around this, all rewriting is done in the first virtual host and then the final request after its been re-written is passed to the second virtual host, which then goes and does what its supposed to. This is a config from mod_cluster 1.0.1.GA, as I've only just upgraded to mod_cluster 1.0.2.GA I have not tried combining the two virtual hosts into 1 virtual host again.

      That said, I should make it clear that this problem also occurred in mod_cluster 1.0.1.GA. That is also the earliest version of mod_cluster I've used.

      Can someone please explain to me why I need to have that seemingly useless ProxyPass in the first VirtualHost entry above? Is it a bug or is it something else?

      Thanks.