Jump to content

Recommended Posts

Posted

apache_http_server_logo.jpg

 

In this tutorial we will see the principles on how to secure our Apache Web Server. The Apache HTTP Server has a good record for security but there are some basic things we can do to make Apache a more secure Web server.

 

About Apache HTTP Server.

 

The Apache HTTP Server Project is a collaborative software development effort aimed at creating a robust, commercial-grade, featureful, and freely-available source code implementation of an HTTP (Web) server.

 

The project is jointly managed by a group of volunteers located around the world, using the Internet and the Web to communicate, plan, and develop the server and its related documentation. This project is part of the Apache Software Foundation. In addition, hundreds of users have contributed ideas, code, and documentation to the project.

 

(Note: For the Purpose of this tutorial we will use BackBox (Based on Ubuntu) as OS and Apache2. There are no guarantees or absolutes for Apache security things, so proceed at your own risk.)

 

First let’s locate in which directory Apache running by typing the following command:

 

ps -ef | grep apache

 

root      1443     1  0 16:57 ?        00:00:00 /usr/sbin/apache2 -k start
root      2741  2118  0 18:21 pts/0    00:00:00 grep apache
www-data  5569  1443  0 17:06 ?        00:00:00 /usr/sbin/apache2 -k start

 

As we can see typing the above command Apache appears to be running in the following directory

 

/usr/sbin/apache2

 

(Note: Directory may differ from yours. Depends on the installation process if you change the destination folder during that and from the OS that is used.)

 

Next let’s take some important information about Apache like version and which file we will modify (httpd.conf, apache2.conf, etc). We can use a lot of ways to get a couple of information about the web server. So, on terminal we type one of the following ways:

 

curl -I [url=http://www.example.com]www.example.com[/url] 

 

or

 

/usr/sbin/apache2 -V 

 

or

 

apache -V 

 

(Note: With or without directory we take the same information. If we use -v instead of -V we get only the Server Version/built information.Change the directory with yours if differs)

 

Server version: Apache/2.2.16 (Debian)
Server built:   Apr  1 2012 06:40:08
Server's Module Magic Number: 20051115:24
Server loaded:  APR 1.4.2, APR-Util 1.3.9
Compiled using: APR 1.4.2, APR-Util 1.3.9
Architecture:   32-bit
Server MPM:     Prefork
threaded:     no
forked:     yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/apache2"
-D SUEXEC_BIN="/usr/lib/apache2/suexec"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="mime.types"
-D SERVER_CONFIG_FILE="apache2.conf"

 

As we can see current version of Apache is 2.2.17, if not install/update the latest one. Also the line -D HTTPD_ROOT=”/etc/apache2″ specifies the location of the httpd.conf file and on line -D SERVER_CONFIG_FILE=”apache2.conf” we can verify in which file we ‘ll make the changes.

 

(Note: If the file on line -D SERVER_CONFIG_FILE= differs; you will make the changes to this one)

 

(Note: The httpd.conf file may be empty if your try to open it)

 

Set the right User:Group

 

First we open the apache2.conf file and we make sure that the lines

 

User
Group

 

are set to

 

User apache
Group apache 

 

Hiding and modifying Apache server information

 

Next an important think is to disable a couple of information like (Apache Version, OS configurations, Php configurations) that appears on broken pages

 

badurl.png

 

To hide this information we must add the following options.

 

# ServerSignature Off means that Apache will not display the server version
# on error pages, or in other pages that generates.
ServerSignature Off

# ServerTokens Prod tells apache to only return Apache in the Server header,
# returned on every page request.
ServerTokens Prod 

 

(Note: If you are using Debian or Ubuntu as OS you must do the above changes to the file /etc/apache2/conf.d/security otherwise or in apache2.conf or in httpd.comf file, it depends which OS are you using)

 

Hide PHP Version

 

Next we will modify the php.ini file. On terminal type:

 

nano /etc/php5/apache2/php.ini

 

and find and change the expose_php to off

 

expose_php = Off

 

Protecting System Settings and Server Files

 

Stop users from setting up .htaccess files which can override security features you’ve configured adding the following lines to the server configuration:

 

<Directory />
AllowOverride None
</Directory>

 

Next will disable access to the entire file system except for the directories that are explicitly allowed later.

 

<Directory />
Order Deny,Allow
Deny from all
</Directory>

 

Next will allow access to the specific directories prohibiting default access to the filesystem locations.

 

<Directory "/webdirectory">
Order Deny,Allow
Allow from all
</Directory>

 

<Directory "/var/www/*">

Order Allow,Deny

Allow from all

</Directory>

 

(Note: <Directory /*/public_html> will not match /home/user/public_html, but <Directory /home/*/public_html> will match.)

 

Restricting Access by IP

 

To restrict access by ip add the following lines:

 

Order Deny,Allow
Deny from all
Allow from 127.0.0.1

 

Turn off .htaccess

 

You can do that by adding the following line inside a Directory blog.

 

AllowOverride None

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • This update resaves 25_25 from the original (with sounds) (without the cave below) Some emitter fixes (removed waterfalls with high-poly meshes) The geodata is old, but it works Everything else is unchanged Download P.S. The effect files are taken from the high client for Interlude, so if you're experiencing critical skills, use the default ones for your Version.  
    • GX-Ext Which file of the svn files should i edit to make blow skills to have 100% chance so i can add the settings in the IlExt.ini? because when im changing it from the skilldata.txt it just helps
    • 我们感谢您的 反馈 并希望让服务变得更加 优秀! 如果您使用过我们的服务并愿意分享您的体验(任何体验——积极或建设性),请在Trustpilot上留下评价,并获得$1作为感谢。 链接: https://www.trustpilot.com/review/socnet.pro 如何获得奖励: 1. 前往Trustpilot并留下您的评价 2. 向我们发送发布确认截图,以及带有与评价用户名一致的授权账户截图。 3. 指定哪个商店应收到这 $1 奖励。根据商店不同,可能需要您的用户名/电子邮箱。 您的反馈帮助我们成长,并让项目对社区中的每一位成员变得更好。感谢您与我们同行! 条款: 此活动仅适用于一个唯一用户。不允许多账号行为。 项目有效链接: 数字商品商店(网站): 前往 商店 Telegram 机器人: 前往 – 通过 Telegram 方便访问商店。 虚拟号码服务: 前往 用于购买 Telegram Stars 的 Telegram 机器人: 前往 – 在 Telegram 中快捷且优惠地购买 Stars。 SMM 面板: 前往 – 推广您的社交媒体账户。 我们想向您展示当前的 促销和特别优惠列表 用于购买我们提供的产品与服务: 1. 您可在首次购买时使用优惠码:SOCNET(15% 折扣) 2. 获得 $1 商店余额或 10–20% 折扣——只需在我们网站注册后,按照模板填写您的用户名:“SEND ME BONUS, MY USERNAME IS...”并在我们的论坛主题中发布! 3. 首次启动 SMM 面板可获得 $1:只需在我们的网站(Support)提交主题为 “Get Trial Bonus” 的工单。 4. 我们的 Telegram 频道以及 Stars 购买机器人中每周都有 Telegram Stars 抽奖! 新闻: ➡ Telegram 频道: https://t.me/accsforyou_shop ➡ WhatsApp 频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器: https://discord.gg/y9AStFFsrh 联系方式与支持: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • 我们感谢您的 反馈 并希望让服务变得更加 优秀! 如果您使用过我们的服务并愿意分享您的体验(任何体验——积极或建设性),请在Trustpilot上留下评价,并获得$1作为感谢。 链接: https://www.trustpilot.com/review/socnet.pro 如何获得奖励: 1. 前往Trustpilot并留下您的评价 2. 向我们发送发布确认截图,以及带有与评价用户名一致的授权账户截图。 3. 指定哪个商店应收到这 $1 奖励。根据商店不同,可能需要您的用户名/电子邮箱。 您的反馈帮助我们成长,并让项目对社区中的每一位成员变得更好。感谢您与我们同行! 条款: 此活动仅适用于一个唯一用户。不允许多账号行为。 项目有效链接: 数字商品商店(网站): 前往 商店 Telegram 机器人: 前往 – 通过 Telegram 方便访问商店。 虚拟号码服务: 前往 用于购买 Telegram Stars 的 Telegram 机器人: 前往 – 在 Telegram 中快捷且优惠地购买 Stars。 SMM 面板: 前往 – 推广您的社交媒体账户。 我们想向您展示当前的 促销和特别优惠列表 用于购买我们提供的产品与服务: 1. 您可在首次购买时使用优惠码:SOCNET(15% 折扣) 2. 获得 $1 商店余额或 10–20% 折扣——只需在我们网站注册后,按照模板填写您的用户名:“SEND ME BONUS, MY USERNAME IS...”并在我们的论坛主题中发布! 3. 首次启动 SMM 面板可获得 $1:只需在我们的网站(Support)提交主题为 “Get Trial Bonus” 的工单。 4. 我们的 Telegram 频道以及 Stars 购买机器人中每周都有 Telegram Stars 抽奖! 新闻: ➡ Telegram 频道: https://t.me/accsforyou_shop ➡ WhatsApp 频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器: https://discord.gg/y9AStFFsrh 联系方式与支持: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock