Home Linux & Systems Cybersecurity Cloud & DevOps Networks & Infrastructure SIEM & Monitoring DFIR & Threat Intel Development & Other All categories Projects About Tools

Apache SSL configuration in GNU/Linux

Leer en espanol
Apache SSL configuration in GNU/Linux

Table of contents

Once we have purchased the certificate ===

In this article we explain how to install the SSL certificate and/or the certification authority (CA) certificate on our Apache 2.4 web server

Once we have purchased the SSL certificate and the corresponding validation process has been carried out by the Certification Authority (CA) that issues it, it sends us the already validated SSL certificate. It is usually sent in the form of attached files, or also as text that we must separate and place in the appropriate .crt files following our provider's instructions.

We enable the SSL Module

Redhat and derivatives:

Bash
yum install mod_ssl.x86_64

Debian and derivatives:

Bash
apt install openssl ssl-cert
a2enmod ssl

Suse

text
a2enmod ssl

«ssl» already present

We access /etc/sysconfig/apache2 and we modify the following line:

text
APACHE_SERVER_FLAGS=»SSL»

We restart the service

Bash
service apache2 reload

We edit the file /etc/apache2/listen.conf and it should look like this:

Apache
<IfDefine SSL>

<IfDefine !NOSSL>

<IfModule mod_ssl.c>
Listen 443

NameVirtualHost *:443
</IfModule>

</IfDefine>

</IfDefine>

We check that we have correctly activated the module on our GNU/Linux server

text
httpd -M
ssl_module (shared)

We create the directory where the certificate will be housed:

Redhat and derivatives:

Bash
mkdir /etc/httpd/certs/

Suse, Debian and derivatives:

Bash
mkdir /etc/apache2/certs/

We create the virtualhost with the SSL configuration

When configuring you have to take into account where the settings are located depending on the operating system:

Redhat and Derivatives:

text
/etc/httpd/conf.d/

Suse, Debian and derivatives:

text
/etc/apache2/conf.d/

VirtualHost:

Apache
<VirtualHost *:80>

ServerAdmin wadmin@red-orbita.com

DocumentRoot «/var/www/html/»

ServerName red-orbita.com

ServerAlias red-orbita.com

ErrorLog «/var/log/httpd/red-orbita.com-error_log»

CustomLog «/var/log/httpd/red-orbita.com-access_log» combined
#Redireccionamos al puerto https
Redirect permanent / https://tpldes.madrilena.es/
<Directory «/var/www/html/»>

DirectoryIndex index.html index.php

Options FollowSymLinks

AllowOverride All

Require all granted

</Directory>
</VirtualHost>
<VirtualHost _default_:443>
ServerAdmin wadmin@red-orbita.com

DocumentRoot «/var/www/html/»

ServerName red-orbita.com

ServerAlias red-orbita.com

ErrorLog «/var/log/httpd/red-orbita.com -ssl-error_log»

CustomLog «/var/log/httpd/red-orbita.com -ssl-access_log» combined
<Directory «/var/www/html/»>

DirectoryIndex index.html index.php

Options FollowSymLinks

AllowOverride All

Require all granted

</Directory>
SSLProtocol ALL -SSLv2 -SSLv3

SSLHonorCipherOrder On

SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS

SSLCompression Off
SSLEngine on

SSLProxyEngine on

SSLProxyCheckPeerName off

SSLProxyCheckPeerCN off

SSLProxyProtocol +TLSv1
SSLCertificateFile /etc/httpd/certs/red-orbita.com.crt

SSLCertificateKeyFile /etc/httpd/certs/red-orbita.com.key

</VirtualHost>

All the best

:wq!

Comments