Creating a Maintenance Page

From EPrints Documentation
Revision as of 09:30, 27 July 2017 by Drn@ecs.soton.ac.uk (talk | contribs) (Added page about creating a maintenance page for your repository.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Sometimes there is a need to be able to completely disable access to content on your repository but you want users to be aware that the repository is just unavailable temporarily for scheduled maintenance, which turning off you web server would not be possible. A common situation where you may want to do this is when you need to make alterations to the database and you want to ensure this does not otherwise change whilst you are making these alterations. The best way of doing this is to create a maintenance page, for which requests to you repository will be redirected.

The following gufile paths ide provides instructions on how to produce a fully branded scheduled maintenance page. It is based on approach originally developed for the CentOS 7 Linux but should work more generally but file paths are liable to be different. Simarly, if you running Apache 2.2, then the Require all granted line will be different (see [1])

1. On the repository's server, as root copy the who of the archive's cfg/static/ directory to /var/www/html/maintenance. E.g.

cp -r /opr/eprints3/archives/example/cfg/static/ /var/www/maintenance

2. Move to the /var/www/maintenance/ directory and download the homepage of your repostistory. E.g.

wget -O index.html http://eprints.example.org/

3. Edit /var/www/maintenance/index.html and insert the following HTML markup, adjustting the dates, time and REPOSITORY_NAME as appropriate. Where to put this will vary between repository it is usually best placed after the title in the main content part od you page:

          <img alt="Warning" src="/style/warning.png" />

Notice of Scheduled Maintenance

Please note that REPOSITORY_NAME will be unavailable from XX:XX on DD/MM/YYYY until XX:XX on DD/MM/YYYY due to scheduled maintenance. We apologise for any inconvenience.

4. In /root/' create a file called eprints-maintenance.conf and add the follwoing contents. Updating ServerName and ServerAdmin as appropriate:

<VirtualHost *:80>
    ServerName eprints.example.org
    ServerAdmin eprints@example.org

    DocumentRoot /var/www/maintenance
    <Directory /var/www/maintenance/>
        Options +Indexes +FollowSymLinks +MultiViews
        Require all granted
        RewriteEngine On
        RewriteCond %{REQUEST_URI} !(index|style|javascript|images)
        RewriteRule ^ /index.html [R=302]
    </Directory>

    ErrorLog logs/error_log
    TransferLog logs/access_log
    LogLevel warn
</VirtualHost>

5. If your repository uses HTTPS you will also need to create a file called eprints-maintenance-ssl.conf with the following contents. Updating ServerName and ServerAdmin as appropriate:

<VirtualHost *:443>
    ServerName eprints.example.org
    ServerAdmin eprints@example.org

    SSLProtocol all -SSLv2 -SSLv3
    SSLHonorCipherOrder on
    SSLCipherSuite HIGH:!aNULL:!eNULL:!kECDH:!aDH:!RC4:!3DES:!CAMELLIA:!MD5:!PSK:!SRP:!KRB5:@STRENGTH
    SSLCertificateFile /opt/eprints3/archives/example/ssl/eprints.example.org.crt
    SSLCertificateKeyFile /opt/eprints3/archives/example/ssl/eprints.example.org.key
    SSLCertificateChainFile /opt/eprints3/archives/example/ssl/eprints.example.org.ca-bundle

    DocumentRoot /var/www/maintenance
    <Directory /var/www/maintenance/>
        Options +Indexes +FollowSymLinks +MultiViews
        Require all granted
        RewriteEngine On
        RewriteCond %{REQUEST_URI} !(index|style|javascript|surrey)
        RewriteRule ^ /index.html [R=302]
    </Directory>

    SetEnvIf User-Agent ".*MSIE.*" \
        nokeepalive ssl-unclean-shutdown \
        downgrade-1.0 force-response-1.0
    CustomLog logs/ssl_request_log \
         "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

    ErrorLog logs/ssl_error_log
    TransferLog logs/ssl_access_log
    LogLevel warn
</VirtualHost>

6. Next you will need to find the line in /etc/httpd/' (On RHEL/CentOS/Fedora) or /etc/apache2/ (on Ubuntu/Debian):

Include /opt/eprints3/cfg/apache.conf

and comment it out and below put the line:

Include /root/eprints-maintenance.conf

7. Again if you are running HTTPS on you repository you will need to find the following or similar line in /etc/httpd/' or /etc/apache2/:

Include /opt/eprints3/archives/*/ssl/securevhost.conf

and comment it out and below put:

Include /root/eprints-maintenance-ssl.conf

8. Finally, you will need to restart the webserver:

apachectl restart

You should now see that any request to your repository is redirected to /index.html (e.g. http://eprints.example.org/index.html), which displays your maintenance page

Once maintenance is complete all you need to do is uncomment the line(s) commented out in step 6 (and step 7) where appropriate and to save time for future scheduled maintenance, comment out the new lines you added. Then just restart the webserver like in step 8.

If you have planned maintenance again, assuming your branding does not change in the meantime, all you need to do is update the times in /var/www/maintenance/index.html uncomment and comment out the lines in steps 6 and 7 as appropriate and restart the webserver and your maintenance page is backe in place.