0

I'm on a RHEL 8 machine and use Apache httpd to display severel vHosts. I want to redirect all requests to a maintenance page when error code 503 is returned.

My vHost configuration looks like this:

<VirtualHost *:80>
    ServerName example.de 
    DocumentRoot "/var/www/html/gis"

    RewriteEngine  on
    Redirect permanent ^/$          https://example.de/intelliform/ui/cases/-/gis/index#/
    Redirect permanent index.html   https://example.de/intelliform/ui/cases/-/gis/index#/

    RequestHeader set X-Forwarded-Proto "https"
    RequestHeader set X-Forwarded-Port  "443"


    # Konfiguration für mod_proxy
    ProxyPreserveHost On
    ProxyPass /intelliform balancer://lb/intelliform
    ProxyPassReverse /intelliform balancer://lb/intelliform
    # Muss mindestens so groß sein wie LimitRequestFieldSize in intelliform.conf
    ProxyIOBufferSize 16384
    # ProxyTimeout erhöhen, z.B. relevant beim Publizieren von Themes
    #ProxyTimeout 360

    # Konfiguration für mod_jk
    # HTTPS-Anfragen die im Pfad-Anteil mit "/intelliform/" anfangen ueber den Worker "intelliform" verarbeiten
    #JkMount /intelliform/* intelliform

    # Error Page
    ErrorDocument 503 /maintenance.html    

    # Maintenance Page
    # Redirect all request to a 503 return code when in maintenance mode
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteCond /var/www/maintenance/ALL -f
    RewriteCond /var/www/maintenance/%{SERVER_NAME} -f
    RewriteRule %{REQUEST_URI} !=/maintenance.html
    RewriteRule ^ -  [R=503,L]

    # Optional: Fehlerseiten durch eigene Fehlerseiten ersetzen lassen
    # Ab mod_jk 1.2.27 koennen Fehlerseiten die vom intelliForm Server kommen durch eigene Fehlerseiten ersetzt werden.
    # http://tomcat.apache.org/connectors-doc/reference/uriworkermap.html
    
    #ErrorDocument 403 http://www.my-server.example/forbidden.htm
    ErrorDocument 404 /404.htm

    # SSL Config
    # SSL unter Linux
    #SSLEngine on
    #SSLCertificateFile /etc/ssl/certs/serverzertifikat.crt
    #SSLCertificateKeyFile /etc/ssl/certs/meinschluessel.key
    #SSLCACertificateFile /etc/ssl/certs/intermediate-bundle.crt

            <LocationMatch "/+intelliform/admin.*">
                # ohne Beschraenkung verboten
                Require all denied
            </LocationMatch>

            # Zugriff auf intelliform
            <LocationMatch "/+intelliform/+(applications|calendar|data|dwr|filechooser|j_security_check|javascripts|js|properties|autovue|rest|managers/statistic).*|/+intelliform/+[-\w]+\.(css|js|png|gif).*">
                # ohne Beschraenkung erlauben
                Require all granted
            </LocationMatch>

    <Location /services>
                # ohne Beschraenkung verboten
                Require all denied
    </Location>

    <Location /auth>
                ProxyPass http://127.0.0.1:8180/auth
                ProxyPassReverse http://127.0.0.1:8180/auth
                RequestHeader set X-Forwarded-Proto "https"
                RequestHeader set X-Forwarded-Port  "443"
    </Location>
    
    <Location ~ "^/auth(/admin|/*$)">
                Require all granted
    </Location>

    # Logging unter Linux
    # Erstellen Sie mit mit dem Befehl ln -s einen symbolischen Link namens logs im Verzeichnis Ihrer Webserver Installation
    # welche nach /var/log/.. verweist.
    ErrorLog /var/log/httpd/intelliform-error-gis.log
    LogLevel debug
    CustomLog /var/log/httpd/intelliform-access-gis.log combined
    # Kombinierte Log-Datei
   LogFormat "\"%{cache-status}e\" %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" cache_combined
    CustomLog /var/log/httpd/cache-gis.log cache_combined
    #ForensicLog /var/log/httpd/forensic.log

 
</VirtualHost>

This should redirect all requests to a error 503 code when the file ALL oder %{SERVER_NAME} exists. My ErrorDocument is in /var/www/html/gis/maintenance.html, so the root document.

Instead I always get a error 503 Service Unavailable and my maintenance page is not displaying. When I call https://example.com/maintenance.html then my maintenance page is displaying.

How can I fix this issue?

I tried to comment out RewriteConds and simply redirect to error 503 to check if it is configuration issue:

# Maintenance Page
# Redirect all request to a 503 return code when in maintenance mode
#RewriteCond %{ENV:REDIRECT_STATUS} ^$
#RewriteCond /var/www/maintenance/ALL -f
#RewriteCond /var/www/maintenance/%{SERVER_NAME} -f
#RewriteRule %{REQUEST_URI} !=/maintenance.html
RewriteRule ^ -  [R=503,L]

Unfortunately, I still get the Service Unavailable site

3
  • I haven't tested it, but try this: RewriteCond %{DOCUMENT_ROOT}/ALL -f [NC] RewriteRule ^/?$ maintenance.html [R=503,L] - If file "ALL" exists, then redirect everything with 503 to your maintenance page
    – Luis Alberto Barandiaran
    Mar 22 at 15:18
  • I'll try this out on monday and come back to you. I thought it could be the order of directives because I have a Redirect at the beginning of the vHost. Or something with the "ProxyPreserveHost On" directive. When I go to example.com/maintenance.html it can display the maintenance page correctly. So I don't think it has something to do with the file. Mar 23 at 0:20
  • Unfortunately, I still get the Error Service Unavalaible indicating a missconfiguration and I don't know why. It happens immediately after adding the RewriteRule even when I comment out the both Redirect permanent rules at the beginning... Mar 25 at 14:03

0

You must log in to answer this question.

Browse other questions tagged .