10 Replies Latest reply on Aug 25, 2011 6:47 AM by Sebastian Sachtleben

    Jboss 7, mod_cluster and PrettyFaces

    Sebastian Sachtleben Newbie

      I want to provide a cluster of jboss as 7 behind mod_cluster 1.1.3.Final. First jboss runs on port 8088. My mod_cluster configuration is:

       

      1. <IfModule manager_module>
      2.   Listen 127.0.0.1:6666
      3.   ManagerBalancerName mycluster
      4.  
      5.   <VirtualHost 127.0.0.1:6666> 
      6.         KeepAliveTimeout 300
      7.         MaxKeepAliveRequests 0
      8.         AdvertiseFrequency 5
      9.         ServerAdvertise On
      10.  
      11.     <Location />
      12.         Order deny,allow
      13.         Allow from All
      14.     </Location>
      15.   </VirtualHost>
      16. </IfModule>
      17. NameVirtualHost *:80
      18. <VirtualHost *:80> 
      19.     ServerAdmin info@domain.de
      20.     ServerName Name
      21.     ServerAlias www.domain.de www.domain.com
      22.    
      23.     ProxyPass / balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=On
      24.     ProxyPassReverse / balancer://mycluster
      25.  
      26.     <Location />
      27.         Order deny,allow
      28.         Allow from All
      29.     </Location>
      30.  
      31.     <Location /mod_cluster_manager>
      32.        SetHandler mod_cluster-manager
      33.        Order deny,allow
      34.        Deny from all
      35.        Allow from 127.0.0
      36.     </Location>
      37. </VirtualHost>

       

      I have also some other vhosts to provide static access to my repository.

       

      Now I have two problems:

       

      1) The method getRemoteAddr() from HttpServletRequest returns the server ip instead of the client ip. How do I retrieve the client ip with mod_cluster?

       

      2) The RewriteHandler from PrettyFaces (return MappingID on s:viewAction method invoke) redirects to http://www.domain.com//start.html. The getRequestURL() from HttpServletRequest says ttp://www.serverip:8088/start.html. Why occure double slashes with mod_cluster?

       

      Both problems doesnt occure when I browse directly on jboss without mod_cluster.

       

      Any help would be appreciated.

        • 1. Re: Jboss 7, mod_cluster and PrettyFaces
          Radoslav Husar Master

          Hi Sebastian, let me look at #1:

          1) The method getRemoteAddr() from HttpServletRequest returns the server ip instead of the client ip. How do I retrieve the client ip with mod_cluster?

          You should look at what are you doing with that method, see javadoc:

          http://download.oracle.com/javaee/1.4/api/javax/servlet/ServletRequest.html#getRemoteAddr%28%29

           

          It clearly says:

          Returns the Internet Protocol (IP) address of the client or last proxy that sent the request. For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR.

           

          This means you are geetting the IP of the proxy. So for the client you would need to look for a header similar to "x-forwarded-for" or so, not sure what the exact header is.

           

          Rado

          1 of 1 people found this helpful
          • 2. Re: Jboss 7, mod_cluster and PrettyFaces
            Sebastian Sachtleben Newbie

            Thanks Radoslav. Sounds fair enough.

             

            request.getHeader("x-forwarded-for") has the value

             

            But still having the double slash problem...

            • 3. Re: Jboss 7, mod_cluster and PrettyFaces
              Paul Ferraro Master

              Let's see if Jean-Frederic has any insight into the double slash issue.

              • 4. Re: Jboss 7, mod_cluster and PrettyFaces
                Jean-Frederic Clere Master
                • ProxyPass / balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=On
                • ProxyPassReverse / balancer://mycluster

                 

                Do you really need those mod_proxy directives? May be that is the problem.

                • 5. Re: Jboss 7, mod_cluster and PrettyFaces
                  Sebastian Sachtleben Newbie

                  As I said before I need several vhosts to provide static content and I just want the jboss cluster in one vhost. Here is my full configuration:

                   

                  CreateBalancers 1

                  UseAlias 0

                   

                  # MOD_CLUSTER_ADDS

                  # Adjust to you hostname and subnet.

                  <IfModule manager_module>

                    Listen 127.0.0.1:6666

                    ManagerBalancerName mycluster

                   

                    <VirtualHost 127.0.0.1:6666> 

                             KeepAliveTimeout 300

                            MaxKeepAliveRequests 0

                            AdvertiseFrequency 5

                            ServerAdvertise On

                   

                      <Location />

                            Order deny,allow

                            Allow from All

                      </Location>

                    </VirtualHost>

                  </IfModule>

                   

                  NameVirtualHost *:80

                   

                  <VirtualHost *:80> 

                      ServerAdmin info@domain.com

                      ServerName domain

                      ServerAlias www.domain.de www.domain.com

                   

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

                      ProxyPassReverse / balancer://mycluster

                   

                      <Location />

                            Order deny,allow

                            Allow from All

                      </Location>

                   

                      <Location /mod_cluster_manager>

                         SetHandler mod_cluster-manager

                         Order deny,allow

                         Deny from all

                         Allow from 127.0.0

                      </Location>

                  </VirtualHost>

                   

                  <VirtualHost *:80>

                            ServerAdmin info@domain.de

                            ServerName static.domain.de

                            ServerAlias static.domain.de

                   

                            DocumentRoot /PRODUCTION/repository/domain/workspace

                            <Directory /PRODUCTION/repository/domain/workspace/>

                                      Options FollowSymLinks

                                      AllowOverride None

                                      Order Deny,Allow

                                      Allow from all

                            </Directory>

                   

                            ErrorLog "/PRODUCTION/mod_cluster-1.1.3.Final/httpd/logs/error.log"

                   

                            # Possible values include: debug, info, notice, warn, error, crit,

                            # alert, emerg.

                            LogLevel warn

                   

                            CustomLog "/PRODUCTION/mod_cluster-1.1.3.Final/httpd/logs/access.log" combined

                  </VirtualHost>

                   

                  <VirtualHost *:80>

                            ServerAdmin info@domain.com

                            ServerName static.domain.com

                            ServerAlias static.domain.com

                   

                            DocumentRoot /PRODUCTION/repository/domain/workspace

                            <Directory /PRODUCTION/repository/domain/workspace/>

                                      Options FollowSymLinks

                                      AllowOverride None

                                      Order Deny,Allow

                                      Allow from all

                            </Directory>

                   

                            ErrorLog "/PRODUCTION/mod_cluster-1.1.3.Final/httpd/logs/error.log"

                   

                            # Possible values include: debug, info, notice, warn, error, crit,

                            # alert, emerg.

                            LogLevel warn

                   

                            CustomLog "/PRODUCTION/mod_cluster-1.1.3.Final/httpd/logs/access.log" combined

                  </VirtualHost>

                   

                  I have tried to comment out ProxyPassReverse but then the redirect will be end in serverip:8088/requested.html (jboss port directly).

                   

                  It seems like:

                  externalContext.redirect("/requested.html");

                   

                  result in:

                  domain//requested.html

                   

                  Any ideas?

                  • 6. Re: Jboss 7, mod_cluster and PrettyFaces
                    Sebastian Sachtleben Newbie

                    I have fixed it with changing configuration to:

                     

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

                    ProxyPassReverse / balancer://mycluster

                    ProxyPreserveHost On

                     

                    Now everything seems fine

                    • 7. Re: Jboss 7, mod_cluster and PrettyFaces
                      Jean-Frederic Clere Master

                      It seems the ProxyPassReverse / balancer://mycluster is creating the problem.

                      • 8. Re: Jboss 7, mod_cluster and PrettyFaces
                        Sebastian Sachtleben Newbie

                        Should I raise a jira issue?

                         

                        I think it should work without ProxyPreserveHost also or am I wrong?