APACHE2 + SSL

05 marzo, 2006




Esta noche me ha tocado currar un poquito, así que me he puesto a instalar apache2 +SSL.

Así que empezamos:

apt-get install apache2

una vez instalado empezamos a configurarlo para que acepte conexiones SSL.

Vamos a crear los certificados:
Para ellos hacemos:

PACKLAN:/tmp# apache2-ssl-certificate

Y nos saldrá lo siguiente:

creating selfsigned certificate
replace it with one signed by a certification authority (CA)

enter your ServerName at the Common Name prompt

If you want your certificate to expire after x days call this programm
with -days x
Generating a 1024 bit RSA private key
.++++++
.................................................++++++
writing new private key to '/etc/apache2/ssl/apache.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:ES
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company; recommended) []:BARAHACKS
Organizational Unit Name (eg, section) []:
server name (eg. ssl.domain.tld; required!!!) []:localhost
Email Address []:


Completamos estos datos que nos piden, y ya tendremos nuestro certificado, listo para usarlo. Este script de apache nos va a crear el certificado en /etc/apache2/ssl/apache.pem .

Ahora editamos el fichero /etc/apache2/ports.conf, para que quede de la siguiente manera:

Listen 80
Listen 443

Así nuestro servidor escuchará en los puertos 80 (conexiones no seguras) y 443 (conexiones seguras).
Paso siguiente:

ln -s /etc/apache2/ssl/apache.pem /etc/apache2/ssl/server.crt
ln -s /etc/apache2/ssl/apache.pem /etc/apache2/ssl/server.key
cp /etc/apache2/sites-enabled/default /etc/apache2/sites-enabled/default-ssl
vi /etc/apache2/sites-enabled/default-ssl


Y nos debería quedar de la siguiente forma agregando/modificando las lineas que aparecen en negrita.

Ahora queda el paso final :

a2enmod ssl
a2ensite default-ssl
/etc/init.d/apache2 restart

Y ahora probaremos que todo ha ido bien, abriendo en un navegador:
https://localhost/apache2-default/

YA LO TENEMOS FUNCIONANDO!!!

No hay comentarios: