2

We need to have an IP protected Apache. So only a couple of IPs allowed for the whole server. Rest needs to be blocked. However, since all other IPs are blocked, even the custom error documents are blocked?! I've even chmoded these files to 777. My Directory code is below. Welcome any thoughts on how at least the 400.htm and 404.htm can be "allowed" for everyone so they can show up. Thanks.

<VirtualHost *:80>

    DocumentRoot /opt/public
    ServerName xyz.com

    <Directory /opt/public>

            AllowOverride ALL              
            Require all granted
            Options -Indexes

            Order Deny,Allow
            Deny from All
            Allow from 99.99.0.0/16
            Allow from 88.88.0.0/16

            ErrorDocument 403 /opt/public/400.htm
            ErrorDocument 404 /opt/public/404.htm

                <Files 400.htm>
                    <RequireAll>
                    Require all granted
                    Require not env blockAccess
                    </RequireAll>
                </Files>

                <Files ~ "404\.htm$">
                    <RequireAll>
                    Require all granted
                    Require not env blockAccess
                    </RequireAll>
                </Files>

     </Directory>

</VirtualHost>
  • Two things. Do not change file permissions. Second, you are blocking by IP before allowing. See if moving the IP block below the allow error pages help. Be sure to stop and restart Apache before testing. – closetnoc Mar 19 '18 at 16:44
  • @closetnoc, good idea. But that didn't help. Anything else? Should I remove the Files blocks? – Khom Nazid Mar 19 '18 at 17:25
  • You are mixing old style and new style permissions. You should not have Order and Deny mixed with Require. See: httpd.apache.org/docs/current/upgrading.html#access – Stephen Ostermiller Mar 19 '18 at 19:53
  • 1
    You are also requiring the environment variable blockedAccess to not be set to access those files. I'm not sure what would set that variable or why you include that requirement. – Stephen Ostermiller Mar 19 '18 at 19:57
1
ErrorDocument 403 /down.html
<Limit GET POST>
order allow,deny
allow from 200.200.200.200
deny from all
</Limit>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.