76 | | Currently, the Apache webserver is set |
| 76 | Currently, the Apache webserver is set up to proxy requests to the tomcat daemon in charge of a specific environment. The configuration is also already set up to perform loadbalancing. Note that in the configuration below the application context is ''gscf-0.8.3-www'', this should be changed to match the application context on the tomcat server: |
| 77 | |
| 78 | {{{ |
| 79 | root@nmcdsp:/etc/apache2/sites-available# cat nmcdsp.org_gscf-www.conf |
| 80 | # Apache Virtual Host for GSCF Production Build |
| 81 | # |
| 82 | # Author Jeroen Wesbeek <J****n.W******@gmail.com> |
| 83 | # Since 20100825 |
| 84 | # |
| 85 | # Revision Information: |
| 86 | # $Author$ |
| 87 | # $Date$ |
| 88 | # $Rev$ |
| 89 | # |
| 90 | <VirtualHost *:80> |
| 91 | ServerName studies.nmcdsp.org |
| 92 | ServerAlias www.studies.nmcdsp.org gscf.nmcdsp.org www.gscf.nmcdsp.org |
| 93 | |
| 94 | ErrorLog /var/log/apache2/gscf-www-error.log |
| 95 | CustomLog /var/log/apache2/gscf-www-access.log combined |
| 96 | |
| 97 | # Make sure that my document root points to the root of the web |
| 98 | # application (where the WEB-INF is located, for instance). |
| 99 | #DocumentRoot /var/www/nmcdsp.org_www/htdocs |
| 100 | |
| 101 | #ErrorDocument 404 /503.php |
| 102 | |
| 103 | <IfModule mod_rewrite.c> |
| 104 | RewriteEngine on |
| 105 | |
| 106 | # keep listening for the serveralias, but redirect to |
| 107 | # servername instead to make sure only one user session |
| 108 | # is created (tomcat will create one user session per |
| 109 | # domain which may lead to two (or more) usersessions |
| 110 | # depending on the number of serveraliases) |
| 111 | # see gscf ticket #321 |
| 112 | RewriteCond %{HTTP_HOST} ^gscf.nmcdsp.org$ [NC] |
| 113 | RewriteRule ^(.*)$ http://studies.nmcdsp.org$1 [R=301,L] |
| 114 | RewriteCond %{HTTP_HOST} ^www.gscf.nmcdsp.org$ [NC] |
| 115 | RewriteRule ^(.*)$ http://studies.nmcdsp.org$1 [R=301,L] |
| 116 | RewriteCond %{HTTP_HOST} ^www.studies.nmcdsp.org$ [NC] |
| 117 | RewriteRule ^(.*)$ http://studies.nmcdsp.org$1 [R=301,L] |
| 118 | |
| 119 | # rewrite the /gscf-a.b.c-environment/ part of the url |
| 120 | RewriteCond %{HTTP_HOST} ^studies.nmcdsp.org$ [NC] |
| 121 | RewriteRule ^/gscf-0.8.3-www/(.*)$ /$1 [L,PT,NC,NE] |
| 122 | </IfModule> |
| 123 | |
| 124 | <IfModule mod_proxy.c> |
| 125 | <Proxy *> |
| 126 | Order deny,allow |
| 127 | Allow from all |
| 128 | </Proxy> |
| 129 | |
| 130 | ProxyStatus On |
| 131 | ProxyPass / balancer://gscf-cluster/gscf-0.8.3-www/ stickysession=JSESSIONID|jsessionid nofailover=On |
| 132 | ProxyPassReverse / balancer://gscf-cluster/gscf-0.8.3-www/ |
| 133 | ProxyPassReverseCookiePath /gscf-0.8.3-www / |
| 134 | |
| 135 | # backend servlet container for virtual host support. |
| 136 | ProxyPreserveHost On |
| 137 | |
| 138 | # Tell mod_mod proxy that it should not send back the body-content of |
| 139 | # error pages, but be fascist and use its local error pages if the |
| 140 | # remote HTTP stack is sending an HTTP 4xx or 5xx status code. |
| 141 | #ProxyErrorOverride On |
| 142 | |
| 143 | <Location /> |
| 144 | SetOutputFilter proxy-html |
| 145 | ProxyHTMLDoctype XHTML Legacy |
| 146 | ProxyHTMLURLMap /gscf-0.8.3-www/ / |
| 147 | </Location> |
| 148 | |
| 149 | <Proxy balancer://gscf-cluster> |
| 150 | #BalancerMember ajp://localhost:10009 |
| 151 | BalancerMember http://localhost:10080 |
| 152 | </Proxy> |
| 153 | </IfModule> |
| 154 | </VirtualHost> |
| 155 | root@nmcdsp:/etc/apache2/sites-available# |
| 156 | }}} |
| 157 | |
| 158 | Adding more nodes to include in the loadbalanced setup can be done by extending the ''proxy balancer'' configuration directive: |
| 159 | |
| 160 | {{{ |
| 161 | <Proxy balancer://gscf-cluster> |
| 162 | BalancerMember http://node1:port |
| 163 | BalancerMember http://node2:port |
| 164 | ... |
| 165 | BalancerMember http://nodeN:port |
| 166 | </Proxy> |
| 167 | }}} |