{"id":766,"date":"2015-12-09T08:32:48","date_gmt":"2015-12-09T08:32:48","guid":{"rendered":"http:\/\/adriangrigoras.com\/blog\/?p=766"},"modified":"2016-12-09T08:36:30","modified_gmt":"2016-12-09T08:36:30","slug":"13-apache-web-server-security-hardening-tips","status":"publish","type":"post","link":"https:\/\/adriangrigoras.com\/blog\/13-apache-web-server-security-hardening-tips\/","title":{"rendered":"13 Apache Web Server Security and Hardening Tips"},"content":{"rendered":"<p>We all are very familiar with <strong>Apache<\/strong> web server, it is a very popular web server to host your web files or your website on the web. Here are some links which can help you to configure Apache web server on your Linux box.<\/p>\n<div id=\"attachment_4450\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Apache-Security-Tips1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4450\" src=\"http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Apache-Security-Tips1.png\" alt=\"Apache Security Tips\" width=\"320\" height=\"240\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Apache Security and Hardening Tips<\/p>\n<\/div>\n<ol>\n<li><a href=\"http:\/\/www.tecmint.com\/install-apache-mysql-php-on-redhat-centos-fedora\/\" target=\"_blank\">Install Apache Web Server<\/a><\/li>\n<li><a href=\"http:\/\/www.tecmint.com\/creating-your-own-webserver-and-hosting-a-website-from-your-linux-box\/\" target=\"_blank\">Setup Your Website in Your Linux Box<\/a><\/li>\n<\/ol>\n<p>Here in this tutorial, I\u2019ll cover some main tips to secure your web server. Before you apply these changes in your web server, you should have some basics of the Apache server.<\/p>\n<ol>\n<li>Document root Directory: <strong>\/var\/www\/html<\/strong> or <strong>\/var\/www<\/strong><\/li>\n<li>Main Configuration file: <strong>\/etc\/httpd\/conf\/httpd.conf<\/strong> (RHEL\/CentOS\/Fedora) and <strong>\/etc\/apache2\/apache2.conf<\/strong> (Debian\/Ubuntu).<\/li>\n<li>Default HTTP Port: <strong>80<\/strong> TCP<\/li>\n<li>Default HTTPS Port: <strong>443<\/strong> TCP<\/li>\n<li>Test your Configuration file settings and syntax: <strong>httpd -t<\/strong><\/li>\n<li>Access Log files of Web Server: <strong>\/var\/log\/httpd\/access_log<\/strong><\/li>\n<li>Error Log files of Web Server: <strong>\/var\/log\/httpd\/error_log<\/strong><\/li>\n<\/ol>\n<h3>1. How to hide Apache Version and OS Identity from Errors<\/h3>\n<p>When you install <strong>Apache<\/strong> with source or any other package installers like <strong>yum<\/strong>, it displays the <strong>version of your Apache<\/strong> web server installed on your server with the <strong>Operating system name<\/strong> of your server in <strong>Errors<\/strong>. It also shows the information about <strong>Apache modules installed<\/strong> in your server.<\/p>\n<div id=\"attachment_4444\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Show-Apache-Version.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-4444\" src=\"http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Show-Apache-Version-620x396.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Show-Apache-Version-620x396.png 620w, http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Show-Apache-Version.png 1007w\" alt=\"Show Apache Version\" width=\"620\" height=\"396\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Show Apache Version<\/p>\n<\/div>\n<p>In above picture, you can see that <strong>Apache<\/strong> is showing its <strong>version<\/strong> with the <strong>OS installed<\/strong> in your server. This can be a major security threat to your web server as well as your Linux box too. To prevent <strong>Apache<\/strong> to not to display these information to the world, we need to make some changes in Apache main configuration file.<\/p>\n<p><center><\/center>Open configuration file with vim editor and search for \u201c<strong>ServerSignature<\/strong>\u201c, its by default On. We need to <strong>Off<\/strong> these server signature and the second line \u201c<strong>ServerTokens Prod<\/strong>\u201d tells Apache to return only Apache as product in the server response header on the every page request, It suppress the OS, major and minor version info.<\/p>\n<pre># vim \/etc\/httpd\/conf\/httpd.conf (RHEL\/CentOS\/Fedora)\r\n# vim \/etc\/apache2\/apache2.conf (Debian\/Ubuntu)<\/pre>\n<pre>ServerSignature Off\r\nServerTokens Prod<\/pre>\n<pre># service httpd restart (RHEL\/CentOS\/Fedora)\r\n# service apache2 restart (Debian\/Ubuntu)<\/pre>\n<div id=\"attachment_4445\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Hide-Apache-Version.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-4445\" src=\"http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Hide-Apache-Version-620x413.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Hide-Apache-Version-620x413.png 620w, http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Hide-Apache-Version.png 1001w\" alt=\"Hide Apache Version\" width=\"620\" height=\"413\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Hide Apache Version<\/p>\n<\/div>\n<h3>2. Disable Directory Listing<\/h3>\n<p>By default Apache list all the <strong>content<\/strong> of Document root directory in the absence of <strong>index file<\/strong>. Please see the image below.<\/p>\n<div id=\"attachment_4446\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Apache-Directory-Listing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-4446\" src=\"http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Apache-Directory-Listing-620x410.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Apache-Directory-Listing-620x410.png 620w, http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Apache-Directory-Listing.png 1003w\" alt=\"Apache Directory Listing\" width=\"620\" height=\"410\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Apache Directory Listing<\/p>\n<\/div>\n<p>We can <strong>turn off<\/strong> directory listing by using <strong>Options directive<\/strong> in configuration file for a specific directory. For that we need to make an entry in <strong>httpd.conf<\/strong> or <strong>apache2.conf<\/strong> file.<\/p>\n<pre>&lt;Directory \/var\/www\/html&gt;\r\nOptions -Indexes\r\n&lt;\/Directory&gt;<\/pre>\n<div id=\"attachment_4447\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Hide-Apache-Directory-Listing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-4447\" src=\"http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Hide-Apache-Directory-Listing-620x416.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Hide-Apache-Directory-Listing-620x416.png 620w, http:\/\/www.tecmint.com\/wp-content\/uploads\/2013\/10\/Hide-Apache-Directory-Listing.png 1000w\" alt=\"Hide Apache Directory Listing\" width=\"620\" height=\"416\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Hide Apache Directory Listing<\/p>\n<\/div>\n<h3>3. Keep updating Apache Regularly<\/h3>\n<p>Apache developer community is continuously working on <strong>security issues<\/strong> and releasing its <strong>updated version<\/strong> with new <strong>security options<\/strong>. So It is always recommended to use the <strong>latest version<\/strong> of <strong>Apache<\/strong> as your web server.<\/p>\n<p>To check <strong>Apache version<\/strong>: You can check your current version with <strong>httpd -v<\/strong> command.<\/p>\n<pre># httpd -v\r\nServer version: Apache\/2.2.15 (Unix)\r\nServer built:   Aug 13 2013 17:29:28<\/pre>\n<p>You can update your version with the following command.<\/p>\n<pre># yum update httpd\r\n# apt-get install apache2<\/pre>\n<p>It is also recommended to keep your <strong>Kernel<\/strong> and <strong>OS<\/strong> updated to the latest stable releases if you are not running any specific application which works only on specific OS or Kernel.<\/p>\n<h3>4. Disable Unnecessary Modules<\/h3>\n<p>It\u2019s always good to minor the chances of being a victim of any <strong>web attack<\/strong>. So it\u2019s recommended to disable all those <strong>modules<\/strong> that are not in use currently. You can list all the compiled modules of web server, using following command.<\/p>\n<pre># grep LoadModule \/etc\/httpd\/conf\/httpd.conf\r\n# have to place corresponding `LoadModule' lines at this location so the\r\n# LoadModule foo_module modules\/mod_foo.so\r\nLoadModule auth_basic_module modules\/mod_auth_basic.so\r\nLoadModule auth_digest_module modules\/mod_auth_digest.so\r\nLoadModule authn_file_module modules\/mod_authn_file.so\r\nLoadModule authn_alias_module modules\/mod_authn_alias.so\r\nLoadModule authn_anon_module modules\/mod_authn_anon.so\r\nLoadModule authn_dbm_module modules\/mod_authn_dbm.so\r\nLoadModule authn_default_module modules\/mod_authn_default.so\r\nLoadModule authz_host_module modules\/mod_authz_host.so\r\nLoadModule authz_user_module modules\/mod_authz_user.so\r\nLoadModule authz_owner_module modules\/mod_authz_owner.so\r\nLoadModule authz_groupfile_module modules\/mod_authz_groupfile.so\r\nLoadModule authz_dbm_module modules\/mod_authz_dbm.so\r\nLoadModule authz_default_module modules\/mod_authz_default.so\r\nLoadModule ldap_module modules\/mod_ldap.so\r\nLoadModule authnz_ldap_module modules\/mod_authnz_ldap.so\r\nLoadModule include_module modules\/mod_include.so\r\nLoadModule log_config_module modules\/mod_log_config.so\r\nLoadModule logio_module modules\/mod_logio.so\r\nLoadModule env_module modules\/mod_env.so\r\nLoadModule ext_filter_module modules\/mod_ext_filter.so\r\n....<\/pre>\n<p>Above is the list of modules that are enabled by default but often not needed: <strong>mod_imap<\/strong>, <strong>mod_include<\/strong>, <strong>mod_info<\/strong>, <strong>mod_userdir<\/strong>, <strong>mod_autoindex<\/strong>. To disable the particular module, you can insert a \u201c<strong>#<\/strong>\u201d at the beginning of that line and restart the service.<\/p>\n<h3>5. Run Apache as separate User and Group<\/h3>\n<p>With a default installation <strong>Apache<\/strong> runs its process with user <strong>nobody<\/strong> or <strong>daemon<\/strong>. For security reasons it is recommended to run <strong>Apache<\/strong> in its own <strong>non-privileged<\/strong> account. For example: <strong>http-web<\/strong>.<\/p>\n<h5>Create Apache User and Group<\/h5>\n<pre># groupadd http-web\r\n# useradd -d \/var\/www\/ -g http-web -s \/bin\/nologin http-web<\/pre>\n<p>Now you need to tell <strong>Apache<\/strong> to run with this new user and to do so, we need to make an entry in <strong>\/etc\/httpd\/conf\/httpd.conf<\/strong> and restart the service.<\/p>\n<p>Open <strong>\/etc\/httpd\/conf\/httpd.conf<\/strong> with vim editor and search for keyword \u201c<strong>User<\/strong>\u201d and \u201c<strong>Group<\/strong>\u201d and there you will need to specify the <strong>username<\/strong> and <strong>groupname<\/strong> to use.<\/p>\n<pre>User http-web\r\nGroup http-web<\/pre>\n<h3>6. Use Allow and Deny to Restrict access to Directories<\/h3>\n<p>We can restrict access to directories with \u201c<strong>Allow<\/strong>\u201d and \u201c<strong>Deny<\/strong>\u201d options in <strong>httpd.conf<\/strong> file. Here in this example, we\u2019ll be securing <strong>root directory<\/strong>, for that by setting the following in the <strong>httpd.conf<\/strong> file.<\/p>\n<pre>&lt;Directory \/&gt;\r\nOptions None\r\nOrder deny,allow\r\nDeny from all\r\n&lt;\/Directory&gt;<\/pre>\n<ol>\n<li><strong>Options \u201cNone\u201d<\/strong> \u2013 This option will not allow users to enable any optional features.<\/li>\n<li><strong>Order deny, allow<\/strong> \u2013 This is the order in which the \u201c<strong>Deny<\/strong>\u201d and \u201c<strong>Allow<\/strong>\u201d directives will be processed. Here it will \u201c<strong>deny<\/strong>\u201d first and \u201c<strong>allow<\/strong>\u201d next.<\/li>\n<li><strong>Deny from all<\/strong> \u2013 This will deny request from everybody to the <strong>root directory<\/strong>, nobody will be able to access root directory.<\/li>\n<\/ol>\n<h3>7. Use mod_security and mod_evasive Modules to Secure Apache<\/h3>\n<p>These two modules \u201c<strong>mod_security<\/strong>\u201d and \u201c<strong>mod_evasive<\/strong>\u201d are very popular modules of Apache in terms of security.<\/p>\n<h4>Mod_security<\/h4>\n<p>Where <strong>mod_security<\/strong> works as a <strong>firewall<\/strong> for our web applications and allows us to <strong>monitor traffic<\/strong> on a real time basis. It also helps us to protect our websites or web server from <strong>brute force attacks<\/strong>. You can simply install <strong>mod_security<\/strong> on your server with the help of your default package installers.<\/p>\n<h5>Install mod_security on Ubuntu\/Debian<\/h5>\n<pre>$ sudo apt-get install libapache2-modsecurity\r\n$ sudo a2enmod mod-security\r\n$ sudo \/etc\/init.d\/apache2 force-reload<\/pre>\n<h5>Install mod_security on RHEL\/CentOS\/Fedora\/<\/h5>\n<pre># yum install mod_security\r\n# \/etc\/init.d\/httpd restart<\/pre>\n<h5>Mod_evasive<\/h5>\n<p><strong>mod_evasive<\/strong> works very efficiently, it takes one request to process and processes it very well. It prevents <strong>DDOS attacks<\/strong> from doing as much damage. This feature of <strong>mod_evasive<\/strong> enables it to handle the <strong>HTTP brute force<\/strong>and <strong>Dos<\/strong> or <strong>DDos<\/strong> attack. This module detects attacks with three methods.<\/p>\n<ol>\n<li>If so many requests come to a same page in a few times per second.<\/li>\n<li>If any child process trying to make more than <strong>50<\/strong> concurrent requests.<\/li>\n<li>If any <strong>IP<\/strong> still trying to make new requests when its temporarily <strong>blacklisted<\/strong>.<\/li>\n<\/ol>\n<p><strong>mod_evasive<\/strong> can be installed directly from the source. Here, we have an Installation and setup guide of these modules which will help you to set up these Apache modules in your Linux box.<\/p>\n<ol>\n<li><a href=\"http:\/\/www.tecmint.com\/protect-apache-using-mod_security-and-mod_evasive-on-rhel-centos-fedora\/\" target=\"_blank\">Protect Apache using Mod_Security and Mod_evasive<\/a><\/li>\n<\/ol>\n<h3>8. Disable Apache\u2019s following of Symbolic Links<\/h3>\n<p>By default <strong>Apache<\/strong> follows <strong>symlinks<\/strong>, we can <strong>turn off<\/strong> this feature with <strong>FollowSymLinks<\/strong> with <strong>Options directive<\/strong>. And to do so we need to make the following entry in main configuration file.<\/p>\n<pre>Options -FollowSymLinks<\/pre>\n<p>And, if any particular <strong>user<\/strong> or <strong>website<\/strong> need <strong>FollowSymLinks<\/strong> enable, we can simply write a rule in \u201c<strong>.htaccess<\/strong>\u201d file from that website.<\/p>\n<pre># Enable symbolic links\r\nOptions +FollowSymLinks<\/pre>\n<p><strong>Note:<\/strong> To enable rewrite rules inside \u201c<strong>.htaccess<\/strong>\u201d file \u201c<strong>AllowOverride All<\/strong>\u201d should be present in the main configuration globally.<\/p>\n<h3>9. Turn off Server Side Includes and CGI Execution<\/h3>\n<p>We can <strong>turn off<\/strong> server side includes (<strong>mod_include<\/strong>) and <strong>CGI<\/strong> execution if not needed and to do so we need to modify main configuration file.<\/p>\n<pre>Options -Includes\r\nOptions -ExecCGI<\/pre>\n<p>We can do this for a particular directory too with Directory tag. Here In this example, we are <strong>turning off<\/strong> Includes and Cgi file executions for \u201c<strong>\/var\/www\/html\/web1<\/strong>\u201d directory.<\/p>\n<pre>&lt;Directory \"\/var\/www\/html\/web1\"&gt;\r\nOptions -Includes -ExecCGI\r\n&lt;\/Directory&gt;<\/pre>\n<p>Here are some other values with can be <strong>turned On<\/strong> or <strong>off<\/strong> with Options directive.<\/p>\n<ol>\n<li><strong>Options All<\/strong> \u2013 To enable All options at once. This is the default value, If you don\u2019t want specify any values explicitly in Apache conf file or .htaccess.<\/li>\n<li><strong>Options IncludesNOEXEC<\/strong> \u2013 This option allows server side includes without the execute permission to a command or cgi files.<\/li>\n<li><strong>Options MultiViews<\/strong> \u2013 Allows content negotiated multiviews with mod_negotiation module.<\/li>\n<li><strong>Options SymLinksIfOwnerMatch<\/strong> \u2013 It\u2019s similar to FollowSymLinks. But, this will follow only when the owner is the same between the link and the original directory to which it is linked.<\/li>\n<\/ol>\n<h3>10. Limit Request Size<\/h3>\n<p>By default <strong>Apache<\/strong> has no limit on the total size of the HTTP request i.e. unlimited and when you allow large requests on a web server its possible that you could be a victim of <strong>Denial of service attacks<\/strong>. We can Limit the requests size of an Apache directive \u201c<strong>LimitRequestBody<\/strong>\u201d with the directory tag.<\/p>\n<p>You can set the value in bytes from <strong>0<\/strong> (<strong>unlimited<\/strong>) to <strong>2147483647<\/strong> (<strong>2GB<\/strong>) that are allowed in a request body. You can set this limit according to your site needs, Suppose you have a site where you allows uploads and you want to limit the upload size for a particular directory.<\/p>\n<p>Here in this example, <strong>user_uploads<\/strong> is a directory which contains files uploaded by users. We are putting a limit of <strong>500K<\/strong> for this.<\/p>\n<pre>&lt;Directory \"\/var\/www\/myweb1\/user_uploads\"&gt;\r\nLimitRequestBody 512000\r\n&lt;\/Directory&gt;<\/pre>\n<h3>11. Protect DDOS attacks and Hardening<\/h3>\n<p>Well, it\u2019s true that you cannot completely protect your web site from <strong>DDos attacks<\/strong>. Here are some directives which can help you to have a control on it.<\/p>\n<ol>\n<li><strong>TimeOut<\/strong> : This directive allows you to set the amount of time the server will wait for certain events to complete before it fails. Its default value is <strong>300 secs<\/strong>. It\u2019s good to keep this value low on those sites which are subject to <strong>DDOS attacks<\/strong>. This value totally depends on kind of request you are getting on your website. <strong>Note<\/strong>: It could pose problems with come<strong> CGI<\/strong> scripts.<\/li>\n<li><strong>MaxClients<\/strong> : This directive allows you to set the limit on connections that will be served simultaneously. Every new connection will be queued up after this limit. It is available with <strong>Prefork<\/strong> and <strong>Worker<\/strong> both <strong>MPM<\/strong>. The default value of it is <strong>256<\/strong>.<\/li>\n<li><strong>KeepAliveTimeout<\/strong> : Its the amount of time the server will wait for a subsequent request before closing the connection. Default value is <strong>5 secs<\/strong>.<\/li>\n<li><strong>LimitRequestFields<\/strong> : It helps us to set a limit on the number of HTTP request\u2019s header fields that will be accepted from the clients. Its default value is <strong>100<\/strong>. It is recommended to lower this value if <strong>DDos attacks<\/strong> are occurring as a result of so many http request headers.<\/li>\n<li><strong>LimitRequestFieldSize<\/strong> : It helps us to set a size limit on the HTTP Request header.<\/li>\n<\/ol>\n<h3>12. Enable Apache Logging<\/h3>\n<p>Apache allows you to logging independently of your <strong>OS logging<\/strong>. It is wise to enable Apache logging, because it provides more information, such as the commands entered by users that have interacted with your Web server.<\/p>\n<p>To do so you need to include the <strong>mod_log_config<\/strong> module. There are three main logging-related directives available with Apache.<\/p>\n<ol>\n<li><strong>TransferLog<\/strong>: Creating a log file.<\/li>\n<li><strong>LogFormat<\/strong> : Specifying a custom format.<\/li>\n<li><strong>CustomLog<\/strong> : Creating and formatting a log file.<\/li>\n<\/ol>\n<p>You can also use them for a particular website it you are doing <strong>Virtual hosting<\/strong> and for that you need to specify it in the virtual host section. For example, here is the my website virtual host configuration with logging enabled.<\/p>\n<pre>&lt;VirtualHost *:80&gt;\r\nDocumentRoot \/var\/www\/html\/example.com\/\r\nServerName www.example.com\r\nDirectoryIndex index.htm index.html index.php\r\nServerAlias example.com\r\nErrorDocument 404 \/story.php\r\nErrorLog <strong>\/var\/log\/httpd\/example.com_error_log<\/strong>\r\nCustomLog <strong>\/var\/log\/httpd\/example.com_access_log combined<\/strong>\r\n&lt;\/VirtualHost&gt;<\/pre>\n<h3>13. Securing Apache with SSL Certificates<\/h3>\n<p>Last, but not the least <strong>SSL certificates<\/strong>, you can secure your all the communication in an encrypted manner over the Internet with SSL certificate. Suppose you have a website in which people login by proving their Login credentials or you have an E- Commerce website where people provides their <strong>bank details<\/strong> or <strong>Debit<\/strong>\/<strong>Credit<\/strong> card details to purchase products, by default your web server send these details in plain \u2013 text format but when you use <strong>SSL certificates<\/strong> to your websites, <strong>Apache<\/strong> sends all this information in encrypted text.<\/p>\n<p>You can <strong>purchase SSl certificates<\/strong> from So many different SSL providers like <strong>namecheap.com<\/strong>. If you are running a very small web business and do not willing to <strong>purchase an SSL certificate<\/strong> you can still assign a <strong>Self signed certificate<\/strong> to your website. <strong>Apache<\/strong> uses the <strong>mod_ssl<\/strong> module to support <strong>SSL certificate<\/strong>.<\/p>\n<pre># openssl genrsa -des3 -out example.com.key 1024\r\n# openssl req -new -key example.com.key -out exmaple.csr\r\n# openssl x509 -req -days 365 -in example.com.com.csr -signkey example.com.com.key -out example.com.com.crt<\/pre>\n<p>Once your certificate has been created and signed. Now you need to add this in Apache configuration. Open main configuration file with vim editor and add the following lines and restart the service.<\/p>\n<pre>&lt;VirtualHost 172.16.25.125:443&gt;\r\nSSLEngine on\r\nSSLCertificateFile \/etc\/pki\/tls\/certs\/example.com.crt\r\nSSLCertificateKeyFile \/etc\/pki\/tls\/certs\/example.com.key\r\nSSLCertificateChainFile \/etc\/pki\/tls\/certs\/sf_bundle.crt\r\nServerAdmin ravi.saive@example.com\r\nServerName example.com\r\nDocumentRoot \/var\/www\/html\/example\/\r\nErrorLog \/var\/log\/httpd\/example.com-error_log\r\nCustomLog \/var\/log\/httpd\/example.com-access_log common\r\n&lt;\/VirtualHost&gt;<\/pre>\n<p>Open up your browser, type <strong>https:\/\/example.com<\/strong>, and you will be able to see the new <strong>self-signed certificate<\/strong>.<\/p>\n<p>These are few security tips that you can use to <strong>secure your Apache web server<\/strong> installation. For more useful security tips and ideas, see the official online documentation of <a href=\"http:\/\/httpd.apache.org\/docs\/2.2\/misc\/security_tips.html\" target=\"_blank\">Apache HTTP Server<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<p>source:\u00a0http:\/\/www.tecmint.com\/apache-security-tips\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We all are very familiar with Apache web server, it is a very popular web server to host your web files or your website on the web. Here are some links which can help you to configure Apache web server on your Linux box. Apache Security and Hardening Tips Install Apache Web Server Setup Your\u2026 <span class=\"read-more\"><a href=\"https:\/\/adriangrigoras.com\/blog\/13-apache-web-server-security-hardening-tips\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-766","post","type-post","status-publish","format-standard","hentry","category-apache"],"_links":{"self":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/posts\/766","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/comments?post=766"}],"version-history":[{"count":1,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/posts\/766\/revisions"}],"predecessor-version":[{"id":767,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/posts\/766\/revisions\/767"}],"wp:attachment":[{"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/media?parent=766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/categories?post=766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adriangrigoras.com\/blog\/wp-json\/wp\/v2\/tags?post=766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}