Webserver redirecting to a maintenance html page on 403 error

Sometimes I restrict access to our Indico instance during maintenance/updates when I want to check something on the website first without other users already accessing and logging in again. I do that by only allowing my ip address which works fine:

###Added to /etc/apache2/sites-available/indico.conf :

<Location "/">
	Require ip my-ip-address
</Location>

However, other users visiting during that time are faced with a 403 Forbidden error page which isn’t very nice and I’d like to redirect them to a simple html page on the same server stating something along the lines of “Maintenance is currently in progress.”
This should be possible with:

###/*Added to /etc/apache2/conf-available/localized-error-pages.conf :

ErrorDocument 403 /opt/indico/customdir/maintenance/maintenance.html

and

###/*Added to /etc/apache2/sites-available/indico.conf :

<Directory "/opt/indico/customdir/maintenance/">
	Require all granted
</Directory>

I’ve tried with a few different file paths like /customdir/maintenance/, /customdir/files/ or even /var/www/html/ but nothing has worked for me so far. I get either the 403 error page (now stating that two 403 errors have occured) or a Not Found Indico page which looks like this:


Permissions on the file and directory are the same as the rest of the customization directory.

I’d be happy if someone could point out any mistakes I made or knows where I can put the html file on the server so that the webserver finds and displays it. Redirecting from the 403 error in itself is possible, I have tried redirecting to an external website and that works just fine.

Sounds like something to better ask in a place about Apache… :wink:

Anyway, try putting it in /var/www/... or whatever the default location is, maybe Apache has no access to send from that /opt/indico/customdir location. Or check the apache error log to see if it has some more information.

Well, I’m not entirely sure I understand where the default location actually is. As per the official installation guide the document root is set to /var/empty/apache, but that directory doesn’t exist so I’m guessing it must be /opt/indico since the same config file grants access there. But then I don’t understand why my html file can’t be found there.

That being said, I found another solution I’m quite happy with. By restricting access to “/login/” instead of “/”, and then redirecting back to “/” on a 403 error users are still able to visit the website and are simply redirected back to the main page whenever they try to access the login page. That way they can also still see the global announcement I put up informing about maintenance windows so there is no need for a seperate html file.

Nonetheless, if anyone has a solution for the original problem I’m still open for advice!