motomac Posted September 22, 2015 Posted September 22, 2015 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.
Management Charles Posted September 22, 2015 Management Posted September 22, 2015 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.
TheSonic Posted September 22, 2015 Posted September 22, 2015 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 )
motomac Posted September 23, 2015 Author Posted September 23, 2015 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.
Paul.F Posted September 23, 2015 Posted September 23, 2015 Use htaccess to rediect that address to a custom page if it goes offline.
Makoto Posted September 23, 2015 Posted September 23, 2015 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 allow 127.0.0.1; deny all; return 503; } # Error pages error_page 500 501 502 503 504 /error/5xx.html; location ^~ /error/ { internal; 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.
TSP Posted September 23, 2015 Posted September 23, 2015 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:127.0.0.1', '::ffff:127.0.0.2') ) ) { require_once('downtime.php'); exit; } } 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.
Nathan Explosion Posted September 23, 2015 Posted September 23, 2015 I usually just rename the index.php, and then rename another file I've got to index.html (or .php, if it's got PHP in it) And reverse once complete.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.