The easiest way to support Tomcat with an Apache HTTP instance

I have one instance of Tomcat 6 that often needs to be rebooted due to PermGen problems after several deployments of WAR.

In a production environment, it is clearly bad practice to delete a site without leaving visitors with anything but a connection failure. The big picture is to create a Tomcat failover cluster from one or two instances, but for now I would like a simple solution:

When Tomcat does not work, all requests are redirected to the Apache HTTP server, which runs one simple page such as "Site under maintenance."

I guess I need a small, super fast proxy to sit in front of Tomcat, feed him requests and monitor my health. If he dies, he simply sends these requests to Apache HTTP.

Ideas?

+3
source share
1 answer

You can simply use Apache before installing tomcat. Set up a proxy forwarding rule for your cat. If this does not work, apache will send a β€œ503 Service Temporarily Unavailable”, which you can configure as your service page.

The apache application file looks something like this:

<VirtualHost *>
    ServerName example.com
    ServerAlias *.example.com
    ServerAdmin admin@example.com

    RewriteEngine on
    RewriteRule ^/static/(.*) /some/path/for/static/files/static/$1 [L]
    RewriteRule ^(.*) http://127.0.0.1:8080$1 [P]

    ErrorLog /var/log/apache2/example/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/example/access.log combined
    ServerSignature On

    ErrorDocument 503 /static/site_down.html
</VirtualHost>

URI (/static/) , . , , () apache tomcat.

ErrorDocument 503 site_down.html, .

mod_rewrite mod_proxy/mod_proxy_http apache2

<Proxy *>
        Order Deny,Allow
        Deny from all
        Allow from all
</Proxy>
+4

Source: https://habr.com/ru/post/1706667/


All Articles