Home > Operation and Maintenance > Apache > Apache server security settings

Apache server security settings

(*-*)浩
Release: 2019-11-26 16:19:37
Original
4729 people have browsed it

Apache server security settings

Securing your web server is very important, which means allowing others to view only some of the information and protecting the data and limiting access.

These are common things to enhance the security of your Apache web server. (Recommended learning: Apache Server)

1. Hide Apache version and operating system information. Apache displays its version and operating system name incorrectly, as shown below Screen shot shown.

Apache server security settings

#Hackers can use this information to launch attacks using exposed vulnerabilities in specific versions of servers or operating systems. To prevent Apache webserver from displaying this information, we can modify the server signature option provided in the apache configuration file. By default it is on, set it to off.

vim /etc/httpd/conf/httpd.conf<br/>
Copy after login

The modification is:

ServerSignature Off<br/>ServerTokens Prod<br/>
Copy after login

We also set up "ServerTokens Prod", which tells the web server to only return apache and prohibits operating system major and minor versions . After modifying the configuration file, the Apache web server must be restarted/reloaded for it to take effect.

service httpd restart<br/>
Copy after login

After modifying and restarting the Apache server, you should see similar results -

Apache server security settings

2. Disable directory listing

If there is no index file in the document root directory (such as: index.html, index.php, index.html, etc.), then by default, the apache web server will display all the contents of the document root directory.

Apache server security settings

This feature can be turned off for a specific directory through the options directive provided in the Apache configuration file.

<Directory /var/www/html><br/>    Options -Indexes<br/></Directory><br/>
Copy after login

Apache server security settings

3. Disable unnecessary modules

It is best to disable all unused unnecessary modules, you can See the list of enabled modules in the apache configuration file -

[root@amsterdam ~]#httpd –M<br/>perl_module (shared)<br/>php5_module (shared)<br/>proxy_ajp_module (shared)<br/>python_module (shared)<br/>ssl_module (shared)<br/>
Copy after login

Many of the listed modules can be disabled like mod_imap, mod_include, mod_info, mod_userdir, mod_autoindex as they are hardly used by any production Used by web server.

vi /etc/httpd/conf/httpd.conf<br/>
Copy after login

Then comment out -

#LoadModule auth_digest_module modules/mod_auth_digest.so<br/>
Copy after login

After commenting the module, save the file. Use the following command to restart the apache service.

/etc/init.d/httpd restart/<br/>
Copy after login

4. Use mod_evasive to counter DoS attacks

If you want to protect your web server from DoS (i.e. Denial of Service), you must enable the module mod_evasive. It is a third-party module that detects DoS attacks and prevents them from causing damage far beyond the course of their operation.

5. Limit request size

Apache does not have any limit on the total size of http requests that may lead to a DoS attack. The request size of the Apache directive LimitRequestBody can be limited using directory tags.

Depending on the requirements, this value can be set from 0 to 2GB (i.e. 2147483647 bytes).

<Directory "/var/www/html/uploads"><br/>   LimitRequestBody 512000<br/></Directory><br/>
Copy after login

The above is the detailed content of Apache server security settings. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template