Ah01797 client denied by server configuration как исправить

Since quite a while (over a month now) I see lines like the following in the apache logs:

180.76.15.138 - - [24/Jun/2015:16:13:34 -0400] "GET /manual/de/mod/module-dict.html HTTP/1.1" 403 396 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"
180.76.15.159 - - [24/Jun/2015:16:28:34 -0400] "GET /manual/es/mod/mod_cache_disk.html HTTP/1.1" 403 399 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"
66.249.75.86 - - [24/Jun/2015:16:18:01 -0400] "GET /manual/es/programs/apachectl.html HTTP/1.1" 403 436 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
[Wed Jun 24 16:13:34.430884 2015] [access_compat:error] [pid 5059] [client 180.76.15.138:58811] AH01797: client denied by server configuration: /usr/share/doc/apache2-doc/manual/de/mod/module-dict.html
[Wed Jun 24 16:18:01.037146 2015] [access_compat:error] [pid 2791] [client 66.249.75.86:56362] AH01797: client denied by server configuration: /usr/share/doc/apache2-doc/manual/es/programs/apachectl.html
[Wed Jun 24 16:28:34.461298 2015] [access_compat:error] [pid 2791] [client 180.76.15.159:25833] AH01797: client denied by server configuration: /usr/share/doc/apache2-doc/manual/es/mod/mod_cache_disk.html

The requests seem to really come from Baiduspider and Googlebot (checked using reverse DNS as explained here):

user@server:~$ host 66.249.75.86
86.75.249.66.in-addr.arpa domain name pointer crawl-66-249-75-86.googlebot.com.
user@server:~$ host crawl-66-249-75-86.googlebot.com
crawl-66-249-75-86.googlebot.com has address 66.249.75.86

I have read similar questions about this topic like this and this, but for those, these errors are actually preventing the site to work correctly. In my case instead, the html pages that the bots try to access do not exist, and this is therefore the expected behaviour of Apache. Only annoyance, is that Google seems slow at indexing my site, although the Google Webmaster Tools do not show any errors.

I am using Apache version 2.4.7 with the following vhost configuration:

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com

    DocumentRoot "/var/www/example.com/public"
    <Directory />
        Options None
        AllowOverride None
        Order Deny,Allow
        Deny from all
        Require all denied
    </Directory>
    <Directory "/var/www/example.com/public">
        Options None
        AllowOverride FileInfo Limit Options=FollowSymLinks 
        Order Allow,Deny
        Allow from all
        Require all granted
    </Directory>

    ErrorLog /var/log/apache2/example.com/error.log
    CustomLog /var/log/apache2/example.com/access.log combined
</VirtualHost>

My questions are therefore:

  1. why are Baiduspider and Googlebot repeatedly trying to access content on my site which is not there and not referred by any links on the site?
  2. how do requests like GET /manual/de/mod/... get mapped to /usr/share/doc/apache2-doc/manual/de/mod/... while, to my understanding, they should go to /var/www/example.com/public/manual/de/mod/...?
  3. in general: should I worry about those lines as a sign of misconfiguration, or is there an explanation for them?

Let’s explore more about the issue “AH01797: client denied by server configuration” in cPanel in this article. Bobcares, as a part of our cPanel & WHM Support Services offers solutions to every query that comes our way.

AH01797: client denied by server configuration in cPanel

Whenever we attempt to browse a website, a 403 forbidden error appears. Additionally, we can see a similar issue to “AH01797: client denied by server configuration” in the website error logs. Include the below code to .htaccess file and prevent the IP address from accessing the website.


    Order allow,deny
    Deny from all

In this case, we should edit the .htaccess file and remove the code which is blocking the IP address or all IP addresses from accessing the website.

AH01797: client denied by server configuration cpanel

Methods To Fix “AH01797: client denied by server configuration” in cPanel?

We have should know certain details before fixing the error “AH01797: client denied by server configuration” in cPanel. It includes the complete file system path where access is not possible, and the IP or hostname of the client as using the correct path in the directory block.

Method 1: In this method, we must confirm the IP address is properly added to any relative “allow” list before restricting any part of the website or application. We should also rename and save the htaccess file as htaccess.txt. Then save the correct PHP version by visiting Software >>> MultiPHP Manager. Also, visit Software >>> MultiPHP Editor or Select PHP Version, select the directory and check PHP values and save it. By doing this, we can create the.htaccess file with its default values.

Method 2: Here, we must confirm to properly include the IP address to any relative “allow” list before restricting any part of the website or application. Then disable any security plugins that add htaccess file directives. After that visually examining the htaccess file to locate and eliminate any rules that are incompatible with server. Fixing of the problem is possible by editing or commenting out the problematic directives in that module. Finally, save the .htaccess file with default settings.

[Looking for an answer to a different question? We are available 24/7.]

Conclusion

In this article, we have provided two simple solutions from our Tech team to fix the error, “AH01797: client denied by server configuration” in cPanel.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

I just installed Magento 2 on HostGator with Linux+Cpanel.

Everything seems to work fine, however, any change I do on the Configuration it keeps loading and loading and never applies.

I checked the server logs and it shows:

[Thu Mar 03 11:40:43 2016] [error] [client 108.167.165.191] client denied by server configuration: /home3/e9u3j7z1/public_html/magento/app/etc/config.php

The file has 644 permission, because it is required by Cpanel, I tried to change it to 755, 777, 775 but it doesn’t solve the problem.

Someone could help?

asked Mar 3, 2016 at 18:22

BrunoBueno's user avatar

1

What is the “Client denied by server configuration app/etc/local.xml” error in Magento?

The “Client denied by server configuration app/etc/local.xml” error in the web server error log represents Magento successfully blocking external access to the sensitive information within that file and reflects the normal, secure operation of your Magento installation.

You may safely ignore this message because it reflects the normal, secure operation of your Magento installation.

If the IP address shown in the log is your site’s IP address, it represents the Magento installation performing a routine security check. Its presence in the error logs indicates that the local.xml file, which contains sensitive credentials, is inaccessible over the Web. Your Magento installation performs this check whenever you log into the administrative control panel of your site.

If the IP address in the log is not your site’s IP address, it reflects a successful block of an external attempt to access this file, and is therefore desirable. The access attempts are sometimes made by automatic site scrapers or bots that search for vulnerable websites.

  • See more at: https://docs.nexcess.net/article/what-is-the-%E2%80%9Cclient-denied-by-server-configuration-app-etc-local-xml%E2%80%9D-error.html#sthash.dIaSybtK.dpuf

answered May 26, 2016 at 14:00

Dayssam's user avatar

DayssamDayssam

1311 silver badge6 bronze badges

3

I had a similar issue with the same error message and it turned out maintenance mode was enabled. Try running this from the root of your install:

php bin/magento maintenance:disable

answered Mar 10, 2016 at 2:24

itsiain's user avatar

Please use this command

find . -type f -exec chmod 644 {} ;                        // 644 permission for files
find . -type d -exec chmod 755 {} ;                        // 755 permission for directory 
find ./var -type d -exec chmod 777 {} ;                // 777 permission for var folder    
find ./pub/media -type d -exec chmod 777 {} ;
find ./pub/static -type d -exec chmod 777 {} ;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml

answered Mar 14, 2017 at 6:26

gelanivishal's user avatar

gelanivishalgelanivishal

1,3061 gold badge12 silver badges25 bronze badges

Just wanted to clarify this for anyone who comes to this page via Google. The “client denied by server configuration” error is produced by Allow / Deny rules you have added or are present in an .htaccess file. You can see this particularly in the error pasted in the last reply…

[access_compat:error] [pid 5933] [client 127.0.0.1:48262] AH01797: client denied by server configuration: /var/www/html/app/etc/config.php

access_compat is an Apache module that allows you to use the old Apache 2.2 Allow and Deny directives in Apache 2.4, although they are deprecated. This gives a clue as to what is preventing access.

I found in my client’s installation, he had an htaccess file inside the /app directory with the following…

Order deny,allow
Deny from all

Commenting those out resolved the problem. Hope this helps anyone having this issue 🙂

answered Dec 2, 2016 at 8:40

Chris's user avatar

ChrisChris

171 bronze badge

2

If you are using .htaccess for directory protection, it appears that it may cause this issue. Try removing it or renaming your .htaccess to test.

answered Dec 19, 2017 at 3:20

ctroyp's user avatar

ctroypctroyp

852 silver badges9 bronze badges

#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See for detailed information.
# In particular, see
#
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They’re here only as hints or reminders. If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server’s control files begin with “/” (or “drive:/” for Win32), the
# server will use that explicit path. If the filenames do *not* begin
# with “/”, the value of ServerRoot is prepended — so ‘log/access_log’
# with ServerRoot set to ‘/www’ will be interpreted by the
# server as ‘/www/log/access_log’, where as ‘/log/access_log’ will be
# interpreted as ‘/log/access_log’.

#
# ServerRoot: The top of the directory tree under which the server’s
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path. If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used. If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot “/etc/httpd”

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen
#Listen

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule’ lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l’) do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache
Group apache

# ‘Main’ server configuration
#
# The directives in this section set up the values used by the ‘main’
# server, which responds to any requests that aren’t handled by a
# definition. These values also provide defaults for
# any containers you may define later in the file.
#
# All of these directives may appear inside containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. admin@your-domain.com
#
ServerAdmin root@localhost

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn’t have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80

#
# Deny access to the entirety of your server’s filesystem. You must
# explicitly permit access to web content directories in other
# blocks below.
#

AllowOverride none
Require all denied

#
# Note that from this point forward you must specifically allow
# particular features to be enabled – so if something’s not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot “/var/www/html”

#
# Relax access to content within /var/www.
#

AllowOverride None
# Allow open access:
Require all granted

# Further relax access to the default document root:

#
# Possible values for the Options directive are “None”, “All”,
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that “MultiViews” must be named *explicitly* — “Options All”
# doesn’t give it to you.
#
# The Options directive is both complicated and important. Please see
# httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None

#
# Controls who can get stuff from this server.
#
Require all granted

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#

DirectoryIndex index.html

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#

Require all denied

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a
# container, that host’s errors will be logged there and not here.
#
ErrorLog “logs/error_log”

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat “%a %l %u %t “%r” %>s %b “%{Referer}i” “%{User-Agent}i”” combined
LogFormat “%a %l %u %t “%r” %>s %b” common

# You need to enable mod_logio.c to use %I and %O
LogFormat “%a %l %u %t “%r” %>s %b “%{Referer}i” “%{User-Agent}i” %I %O” combinedio

#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a
# container, they will be logged here. Contrariwise, if you *do*
# define per- access logfiles, transactions will be
# logged therein and *not* in this file.
#
#CustomLog “logs/access_log” common

#
# If you prefer a logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
CustomLog “logs/access_log” combined

#
# Redirect: Allows you to tell clients about documents that used to
# exist in your server’s namespace, but do not anymore. The client
# will make a new request for the document at its new location.
# Example:
# Redirect permanent /foo www.example.com/bar

#
# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
# Example:
# Alias /webpath /full/filesystem/path
#
# If you include a trailing / on /webpath then the server will
# require it to be present in the URL. You will also likely
# need to provide a section to allow access to
# the filesystem path.

#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the target directory are treated as applications and
# run by the server when requested rather than as documents sent to the
# client. The same rules about trailing “/” apply to ScriptAlias
# directives as to Alias.
#
ScriptAlias /cgi-bin/ “/var/www/cgi-bin/”

#
# “/var/www/cgi-bin” should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#

AllowOverride None
Options None
Require all granted

#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig /etc/mime.types

#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

#
# AddHandler allows you to map certain file extensions to “handlers”:
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add “ExecCGI” to the “Options” directive.)
#
#AddHandler cgi-script .cgi

# For type maps (negotiated resources):
#AddHandler type-map var

#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add “Includes” to the “Options” directive.)
#
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

#
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default. To use the
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
AddDefaultCharset UTF-8

#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type. The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
MIMEMagicFile conf/magic

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 “The server made a boo boo.”
#ErrorDocument 404 /missing.html
#ErrorDocument 404 “/cgi-bin/missing_handler.pl”
#ErrorDocument 402 www.example.com/subscription_info.html
#

#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall may be used to deliver
# files. This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults if commented: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
EnableSendfile on

# Supplemental configuration
#
# Load config files in the “/etc/httpd/conf.d” directory, if any.
IncludeOptional conf.d/*.conf
Include conf/vhosts-default/
Include conf/vhosts/

Best way to fix ‘client denied by server configuration’ in 2021

Welcome to our Knowledge Base

PostedJuly 5, 2022

UpdatedJuly 5, 2022

This kind of error appears on Apache Servers. It means Apache configuration is denying access to a directory/file. Most of the time, this error is observed on Apache 2.4 after upgrading from the older version 2.2 because of the difference in the configuration file syntaxes. Apache 2.4 introduced some changes to authentication and authorization configuration.

To fix the error, you need to make some changes to your Apache configuration which would comply with Apache 2.4 configuration.

Major Changes in version 2.4 to be considered:

    1. Authorization:

Authorization is a way of providing access to some resource/location to someone. All the configuration files using authorization should be changed according to the new changes. Directives controlling the behavior or the way of responding of Authorization when they mismatch with the user being authenticated have been removed in the version 2.4. For example, AuthzOwnerAuthoritative, AuthzDBDAuthoritative, AuthzGroupFileAuthoritative, AuthzLDAPAuthoritative, AuthzUserAuthoritative, and AuthzDBMAuthoritative.

Their replacements in the new version are RequireAll, RequireNone, RequireAny.

    1. Access Control:

In the older version like 2.2, Deny, Allow, Satisfy, Order directives were used to provide access control to the client requests based on a few characteristics like IP, Hostname, etc.

While in 2.4, module mod_authz_host is used for access control. Old access control directives should be replaced by the new ones.

Let’s see a few examples of defining access control in old and new way:

To deny all the requests:

2.2:
Order deny,allow
Deny from all

2.4:
Require all denied

To allow all the requests:

2.2:
Order allow,deny
Allow from all

2.4:
Require all granted

To deny all the requests from all the hosts except example.com:

2.2:

Order Deny,Allow
Deny from all
Allow from example.com

2.4:
Require host example.com

Now, we will try to use old directives in the configuration file of the version 2.4, and see how the server behaves. I have used below code in the configuration file of my website example.com:

<Directory /var/www/example.com/html/test>

Order deny,allow
Deny from all

</Directory>

I have Apache 2.4 running on my server. Now, when I try to access the directory “test”, I get a “403 Forbidden” error like this:

The detailed error from the logs is:

=====
[access_compat:error] [pid 1910] [client 192.168.2.7:50480] AH01797: client denied by server configuration: /var/www/example.com/html/test
=====

This is because I am using old directives like Order, Deny, etc. in the configuration file. If I change this code to below, and restart Apache service, the error will disappear, and I would be able to access the directory “test”:

<Directory /var/www/example.com/html/test>

Require all granted

</Directory>

Now, the directory should be accessible through web like this:

Let’s see this through GIF illustration.

This is my original code using Order, Deny, etc.:

I was seeing below errors:

In the browser:

In the logs:

I changed the code to below, and then restarted the Apache service to fix this error:

The browser shows the index.html page inside the “test” directory successfully now:

Summary:

To fix “client denied by server configuration” error:

  • Remove all the lines containing “Order allow,deny”, “Order deny,allow”
  • “Deny from all” should be replaced by “Require all denied”
  • “Allow from all” should be replaced by “Require all granted”
  • “Allow from example.com” should be replaced by “Require host example.com”
  • Restart Apache service after making changes to the configuration files.

Добавить комментарий