How to show nice error page when your Spring Boot web app is down

23.08.2016 15:30:19

When your web application is starting, it's best to let your clients know that it's temporary and soon you will be up and runnning again:

To make it possible you must have Apache HTTPD up-and-running and it must be an intermediate between your web application and your client. This is best practice anyway. To make it happen, you need in /etc/apache2/sites-available a file named YOUR_APP_NAME.conf:

<VirtualHost *:80>
    ServerAdmin YOUR_EMAIL
    ServerName YOUR_APP_HOST_NAME.com
    ServerAlias *.YOUR_APP_HOST_NAME.com

    # where's customized error message
    DocumentRoot /var/www/html
    ProxyPreserveHost On
    # this URLs won't be served to your web application
    ProxyPass /error-500-YOUR_APP_NAME.html !
    ProxyPass /maintenance.jpg !
    # In case of 503 HTTP error show the error page
    ErrorDocument 503 /error-500-YOUR_APP_NAME.html

    # on which port your web application runs
    ProxyPass           /   http://localhost:8080/
    ProxyPassReverse    /   http://localhost:8080/
    ProxyPassReverseCookiePath  /    /
    ErrorLog /var/log/apache2/YOUR_APP_HOST_NAME.com-error.log
    LogLevel warn
</VirtualHost>




© Jiri Pinkas | this project on GitHub | related: JavaVids | Maven Central Repository Search | Java školení

Top Java Blogs is a Java blog aggregator (with English-written blogs only) focused on Java SE, Java EE, Spring Framework and Hibernate.

Made better & faster using https://www.yourkit.com/ Java Profiler