8 Replies Latest reply: Apr 13, 2012 5:21 AM by Jean-Frederic Clere RSS

Use of named virtualhost

Dirk Gerrit Oort Newbie

Hi,

 

It took me some time to investigate how to use mod_cluster but the most of it works now. I started with the apache server from the mod_cluster download and a as7 instance on the same machine. Indeed this works. The next step was apache on one machine and as7 on another (virtual) machine. Here I had a big problem with multicast. I use Opensuse(12.1) but when you Google on Opensuse and multicast it seems not possible only on the enterprise release. Later on I find out that a simple change in the /etc/sysctl.conf file (change the line with net.ipv4.ip_forward =0 to net.ipv4.ip_forward = 1) on the server will do the trick.

 

The next step use named virtual host and here I encounter lots of problems. And of course it has also to do with my lack of experience. Change the downloaded apache server to use named virtual host was one problem. So my first step was use the apache httpd server of the Opensuse release (2.2.15), add the modules for modcluster named in the documentation.

First activate an ip-based application. This worked.

The second step is to add a virtual host a simple html file with "it works", add a name in the host file.

The next step: use that named virtual host to reach my as7 server. On that server I change the settings (form localhost to 0.0.0.0) to reach also the admin app of the as7 on xxx.xxx.xxx.xxx/ and my app on xxx.xxx.xxx.xxx/simple. And this works. So I could type the named virtual host say http://application and I get the page you normally get on localhost:8080 and http://application/simple Ii get my simple JSF app that also works as Ii expected.

 

But now the last step my simple app must on the root of the address http:/application must give my Welkom file of my JSF app so what apache must do is listen to http://application and redirect to htttp://xxx.xxx.xxx.xxx:8080/simple. I thought change the named virtual host settings little bit. So my line : ProxyPass / balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=On  becomes than ProxyPass / balancer://mycluster/simple stickysession=JSESSIONID|jsessionid nofailover=On and the same for the line with ProxyPassReverse. But this don't works. http://application gives me the as7 page and http://application/simple gives me my working jsf app.

 

So is there somebody who can gives me some hints to solve this.

 

----------------------

 

The failing settings for apache are :

 

<VirtualHost 192.168.0.190:8888>

<Location />

  Order deny,allow

  Deny from all

  Allow from 192.168.0

</Location>

KeepAliveTimeout 60

MaxKeepAliveRequests 0

 

ManagerBalancerName mycluster

ServerAdvertise On

EnableMCPMReceive

</VirtualHost>

 

 

 

named virtual host:

<VirtualHost *>

ServerName application

ErrorLog /var/log/apache2/jboss_a/error.log

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %I %O" extra   

CustomLog /var/log/apache2/jboss_a/access.log extra

 

 

ProxyPass / balancer://mycluster/simple  stickysession=JSESSIONID|jsessionid nofailover=On

ProxyPassReverse /  balancer://mycluster/simple  stickysession=JSESSIONID|jsessionid

 

<Location /mod_cluster_manager>

  SetHandler mod_cluster-manager

  Order deny,allow

  Deny from all

  Allow from 127.0.0

</Location>

</VirtualHost>

  • 1. Re: Use of named virtualhost
    Michal Babacek Novice

    Hi Dirk,

    you may take a look at the undermentioned example. Let's see what it does:

    • You have a balancer running on mybox.com:8887, so you can, in case you can not use multicast, set this on your workers (AS7 standalone-ha.xml, modcluster subsystem):
      • <subsystem xmlns="urn:jboss:domain:modcluster:1.0">
           <mod-cluster-config proxy-list="mybox.com:8887"/>
        </subsystem>
        
    • Advertising is on, so if multicast is available, it goes on 224.0.1.105:6666.
    • Note the important CreateBalancers 1, see docs for details.
    • Further, you have a mybox.com:8888 url. It will display "It works" and mybox.com:8888/mcm will show Mod_cluster manager web page. As soon as there are some nodes (workers) connected, any context like mybox.com:8888/whateverApp will conect you to one of the registered workers.
    • Last but not least, we have a static.mybox.com:8888 virtual host. Any request to, e.g. static.mybox.com:8888/myPicture.jpg will be serverd with contents of /tmp/hudson/httpd/www/html/, statically.

     

    Here we go:

     

     

    # MOD_CLUSTER_ADDS
    CreateBalancers 1
    <IfModule manager_module>
      Listen mybox.com:8887
    
      ManagerBalancerName mycluster
    
      <VirtualHost mybox.com:8887>
            KeepAliveTimeout 300
            MaxKeepAliveRequests 0
            AdvertiseFrequency 5
            ServerAdvertise On
            AdvertiseGroup 224.0.1.105:6666
            EnableMCPMReceive
            <Location />
                Order deny,allow
                Allow from all
            </Location>
      </VirtualHost>
    </IfModule>
    
    Listen 8888
    
    NameVirtualHost mybox.com:8888
    
    <VirtualHost mybox.com:8888>
        ServerName mybox.com
        ServerAlias mybox.com
    
        ProxyPass / balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=On
        ProxyPassReverse / balancer://mycluster
        ProxyPreserveHost On
    
        <Location />
            Order deny,allow
            Allow from all
        </Location>
    
        <Location /mcm>
            SetHandler mod_cluster-manager
            Order deny,allow
            Deny from all
            Allow from all
        </Location>
    </VirtualHost>
    
    NameVirtualHost static.mybox.com:8888
    
    <VirtualHost static.mybox.com:8888>
        ServerName static.mybox.com
        ServerAlias static.mybox.com
    
        DocumentRoot /tmp/hudson/httpd/www/html/
    
        <Directory /tmp/hudson/httpd/www/html/>
            Options FollowSymLinks
            AllowOverride None
            Order Deny,Allow
            Allow from all
        </Directory>
    
    </VirtualHost>
    

     

    Was it helpful? Did I get your question right? Let me know...

     

    BTW: Meh...well, of course, do not copy-paste these Allow from all things :-)

  • 2. Re: Use of named virtualhost
    Dirk Gerrit Oort Newbie

    Sorry Michal, but that was not my problem.

     

    I expected typing the url http://application that my virtual host redirect this towards my jboss server running on an internal ip address:8080 but not the root of that server (xxx.xxx.xxx.xxx:8080) but my jsf application that runs some ware on xxx.xxx.xxx.xxx:8080/application of that jboss server. And let me repeat this putting /application into the balancer link don't works, what i expected.

     

    So how redirect from a virtual host towards an jsf application.

  • 3. Re: Use of named virtualhost
    Jean-Frederic Clere Master

    try ProxyPreserveHost  On in httpd.conf

  • 4. Re: Use of named virtualhost
    Dirk Gerrit Oort Newbie

    Unfortunately it does not work.

    I've add the ProxyPreserveHost on. ( and  ProxyPass / balancer://mycluster/simple) but i must still type the full address http://apllication/simple and not http://application so is this a bug then???

  • 5. Re: Use of named virtualhost
    Jean-Frederic Clere Master

    if you are using ProxyPass / balancer://mycluster/simple you need a ProxyPassReverse / balancer://mycluster/simple for that.

  • 6. Re: Use of named virtualhost
    Michal Babacek Novice

    Hmm, I've just tried this

    Registered contexts on Mod_cluster manager console

    • /SessionTest, Status: ENABLED Request: 0 Disable
    • /, Status: ENABLED Request: 0 Disable

    Application I want to reach with / (as Dirk wants to)

    ProxyPass setting

    • ProxyPass / balancer://mycluster/SessionTest/SessionTestServlet stickysession=JSESSIONID|jsessionid nofailover=On
    • ProxyPassReverse / balancer://mycluster/SessionTest/SessionTestServlet
    • ProxyPreserveHost On

    Result with accessing http://hostname:8888/

    It throws me on / AS7 Status ROOT context, yet I understand that what Dirk would want is to be able to access /SessionTest/SessionTestServlet with / ROOT context....isn't it?

     

    Do I get it right? I am not 100% positive whether it really should work in this way, but mod_proxy documentation suggests that it does. If I leave just:

    • ProxyPass / balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=On
    • ProxyPassReverse / balancer://mycluster
    • ProxyPreserveHost On

    then it works in the way described in my previous post, all contexts on mybox.com:8888 except for /mcm are being routed to registered nodes.

     

    What do you think Jean?

  • 7. Re: Use of named virtualhost
    Dirk Gerrit Oort Newbie

    Ok found something on the apache site:

     

    If the ProxyPass directive scheme starts with the balancer:// (eg: balancer://cluster/, any path information is ignored)  then a virtual worker that does not really communicate with the backend server will be created. Instead it is responsible for the management of several "real" workers. In that case the special set of parameters can be add to this virtual worker. See mod_proxy_balancer for more information about how the balancer works.

     

    Now is the question is if mod_cluster creating this balancer and is there a posibilty to change the path behind the balancer://cluster/ .

  • 8. Re: Use of named virtualhost
    Jean-Frederic Clere Master

    use mod_rewrite for that, something like:

    RewriteRule ^/(.*)$ balancer://cluster/myapp/$1 [L,PT]