Jump to content

Community offline message as static HTML-file


Recommended Posts

When you are working with the server, sometimes you need to switch on/off MySQL server (for example, for upgrade). When it happens visitors see the error page instead of the special page with your message about maintenance work. It would be much better if this page is as independent of the other resources (MySQL) as possible.

Link to comment
Share on other sites

This should not be done in IPS4, because we can not login to the site/ACP in Offlinemode.

But i know what you mean... If i work on PHP, MySQL, etc, i use htaccess to redirect them away from php-files to a static html-site.
And if i work on the webserver itself, well, they get a nasty timeout (moving the DNS for this short period of time would be a bit exaggerated :ph34r::) )

Link to comment
Share on other sites

12 hours ago, Charles said:

I am afraid that's not really possible as without your database the system cannot fetch the setting necessary to know if you have toggled the system offline.

Technically it's possible if use PHP file (independent from MySQL). When administrator switch community off, PHP-file with a message should be generated and some constant like "community_offline" is set to TRUE in config_global.php. Every time when this PHP file is launched it checks community_offline constant, and if it's FALSE, changes routing or redirects to community.

P.S. Anyway ability to switch community ON and OFF from editing config file is a good feature.

Link to comment
Share on other sites

It's a nice idea, but if you're turning the site offline to perform maintenance and relying on a constant to do that, you'll just end up shutting yourself out as well.

If you really want to do that, I'd say the best way of going about it is at the web server level. E.g., with Nginx, to bring the site offline for maintenance while still allowing your IP address access,

location / {
    try_files  $uri $uri/ /index.php;

    # Maintenance response
    deny all;
    return 503;

# Error pages
error_page 500 501 502 503 504 /error/5xx.html;

location ^~ /error/ {
    root /var/www/default;

Write your own custom error page in 5xx.html here and it'll accomplish what you want. I'm sure you can do the same thing with Apache as well.

Link to comment
Share on other sites

I've always done it like this for major upgrades and other prolonged downtimes: 

Before require_once 'init.php'; In index.php I've for example added:

if( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
    $ip_addresses = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
    $ip_address = trim( $ip_addresses[0] );

	/* If the IP address does not equal the following, then show them downpage */
    if( !in_array( $ip_address, array('::ffff:', '::ffff:') ) ) {

If it doesn't require me to see the forum either (for example if I'm still on /admin/upgrade/), then I don't have the IP-check either. 

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...